Tania Rascia

Skip Navigation
WordPress Theme Development: Pagination, Comments, Functions, & Custom Posts

WordPress Theme Development: Pagination, Comments, Functions, & Custom Posts

 /  243 responses

In part one of the tutorial series Developing a WordPress Theme From Scratch, we learned what WordPress is, what it can do, and how to do the following:

  • Set up a local Apache, MySQL, PHP (*AMP) environment
  • Install WordPress on your local server
  • Take an existing static HTML & CSS site and make it into a custom WordPress theme
  • Divide your theme into sections (index.php, header.php, footer.php, sidebar.php, and content.php)
  • Use The Loop to make posts and pages
  • Migrate local WordPress site to a live server

We created this theme using Bootstrap, and more specifically the official generic blog template. While the theme could use custom CSS or any framework, I went with Bootstrap so that we can focus on creating the theme’s function without worrying about the style.

Here is what the theme looked like at the end of the last article:

Very simple, but it effectively demonstrates how to use the WordPress Loop to display content dynamically.

In this article, we’re going to go through more essential WordPress theming techniques.


  • Basic knowledge of HTML and CSS
  • Ability set up WordPress and make a basic theme (covered in part one)


  • Create individual post pages – single.php
  • Add pagination
  • Include comments
  • Learn how to use functions.php
  • Properly enqueue stylesheets and scripts
  • Create global custom fields
  • Create custom post types

First, I’m going to start off by adding individual blog posts and pagination.

Make sure before starting this article you go to Settings > Permalinks. By default, WordPress is set to Day and name. Change this to Post name.

Individual Post Pages

In the last article, we made header, footer, sidebar, content, and page files. Now we’re going to make single.php, which is an individual post page. It’s going to be an exact duplicate of page.php, except I’m going to change 'content' to 'content-single'.

<?php get_header(); ?>

	<div class="row">
		<div class="col-sm-12">

				if ( have_posts() ) : while ( have_posts() ) : the_post();
					get_template_part( 'content-single', get_post_format() );
				endwhile; endif; 

		</div> <!-- /.col -->
	</div> <!-- /.row -->

<?php get_footer(); ?>

Now you’ll create content-single.php, which is a duplicate of content.php.

<div class="blog-post">
	<h2 class="blog-post-title"><?php the_title(); ?></h2>
	<p class="blog-post-meta"><?php the_date(); ?> by <a href="#"><?php the_author(); ?></a></p>
 <?php the_content(); ?>
</div><!-- /.blog-post -->

So now you can see that index.php is pulling in content.php, and single.php is pulling in content-single.php.

Going back to the original content.php, we have the title of each article.

<h2 class="blog-post-title"><?php the_title(); ?></h2>

Using the_permalink(), we’re going to link to the single page.

<h2 class="blog-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

Now you have a blog posts on the main page that are linking individual blog post page.

Finally, we’ll want to change the_content() to the_excerpt() on content.php. The excerpt will only show the first 55 words of your post, instead of the entire contents.

<?php the_excerpt(); ?>


In the original Bootstrap blog example, there is pagination to be able to click through multiple pages if you have many blog posts.

Currently, your index.php file looks like this.

<?php get_header(); ?>

	<div class="row">
		<div class="col-sm-8 blog-main">

			if ( have_posts() ) : while ( have_posts() ) : the_post();
				get_template_part( 'content', get_post_format() );
			endwhile; endif; ?>

		</div>	<!-- /.blog-main -->
		<?php get_sidebar(); ?>
	</div> 	<!-- /.row -->

<?php get_footer(); ?>

If you’ll notice, the loop has if and while, then later endif and endwhile. To insert pagination, we’ll have to put it after the endwhile but before the endif. This means that it won’t repeat for each loop, but will only show up once based on posts.

Pagination links are called like this:

<?php next_posts_link( 'Older posts' ); ?>
<?php previous_posts_link( 'Newer posts' ); ?>

In index.php, between endwhile; and endif;, I’m going to place this code. Make sure to open and close the <?php ?> tags.

	<ul class="pager">
		<li><?php next_posts_link( 'Previous' ); ?></li>
		<li><?php previous_posts_link( 'Next' ); ?></li>

By default, 10 posts will show up on a page before it will link to another page. For testing purposes, I’m going to go to Settings > Reading and change Blog pages show at most to 1.

Now we have functioning pagination.


One of the biggest advantages WordPress and server based content management systems have over static site generators is the ability to include comments without using a third party. (However, static site generators have many more advantages – I have an article on setting up Jekyll if you’re interested in learning how to use them.)

Comments seem complicated to set up, but it doesn’t have to be hard at all. First, we’re going to go back to single.php and enable the comments.

Right now, the code looks like this.

if ( have_posts() ) : while ( have_posts() ) : the_post();
	get_template_part( 'content-single', get_post_format() );
endwhile; endif; 

We’re going to change it to look like this.

if ( have_posts() ) : while ( have_posts() ) : the_post();
	get_template_part( 'content-single', get_post_format() );

	if ( comments_open() || get_comments_number() ) :

endwhile; endif; 

This is just telling the single post to display the comments template. Now we’ll create comments.php.

<?php if ( post_password_required() ) {
} ?>
	<div id="comments" class="comments-area">
		<?php if ( have_comments() ) : ?>
			<h3 class="comments-title">
				printf( _nx( 'One comment on “%2$s”', '%1$s comments on “%2$s”', get_comments_number(), 'comments title'),
					number_format_i18n( get_comments_number() ), get_the_title() );
			<ul class="comment-list">
				wp_list_comments( array(
					'short_ping'  => true,
					'avatar_size' => 50,
				) );
		<?php endif; ?>
		<?php if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
			<p class="no-comments">
				<?php _e( 'Comments are closed.' ); ?>
		<?php endif; ?>
		<?php comment_form(); ?>

Comments are not the simplest part of WordPress theming, but I’ve managed to reduce it down to a small enough code block.

First, we’re setting functionality to prevent users from posting comments if you’ve set your settings to password protected comments (post_password_required()). Then we’re creating a comments div, and if there are comments (have_comments()), it will display how many comments there are on the post (get_comments_number()), followed by the list of comments (wp_list_comments()). If the comments are closed (! comments_open()), it will let you know; at the end will be the form to submit a comment (comment_form()).

Without adding any styles, here is how the functioning single blog post looks.

Obviously the styles aren’t quite there yet, but I don’t want to focus on that in this article. Remove the list-style on the uls, add some padding and margins and possibly some borders and background colors, and you’ll have a much prettier comment setup.

Of course, you might want to show how many comments there are or link to the comments from the main page. You can do that with this code inserted into content.php.

<a href="<?php comments_link(); ?>">
	printf( _nx( 'One Comment', '%1$s Comments', get_comments_number(), 'comments title', 'textdomain' ), number_format_i18n( 						get_comments_number() ) ); ?>

Now that we have pagination, blog posts, and comments set up, we can move on to functions.

Using and Understanding the WordPress Functions File

Located in your theme directory, you can create a file called functions.php. You can use functions.php to add functionality and change defaults throughout WordPress. Plugins and custom functions are basically the same – any code you create can be made into a plugin, and vice versa. The only difference is that anything you place in your theme’s functions is only applied while that theme is actively selected.

I have a README on GitHub of useful WordPress functions, which might come in handy the more you use them.

functions.php seems complicated, but it’s mostly made up of a bunch of code blocks that, simplified, look like this:

function custom_function() {
add_action( 'action', 'custom_function');

So, we’re creating our custom function, and adding it in based on action references. Within this file, you can pretty much change or override anything in WordPress.

Let’s go ahead and make functions.php and place it in our theme directory.

Since it’s a PHP file, it needs to be begin with the opening PHP tag. It doesn’t need a closing tag; pure PHP files don’t need closing tags.


Eventually, you can insert these types of functions into your own custom plugin that can be used across many themes, but for now we’ll learn how to do it in the theme specific file.

Enqueue Scripts and Stylesheets

By the end of the last article, I was incorrectly linking to my CSS and JavaScript in the header and footer, respectively. This should be done through the functions file.

First, delete the links to the stylesheets and scripts that you have in your header and footer. They’re no longer going to be hard coded into the theme.

I’m going to make css, js and images directories in the root of my theme. So here’s what I have:

  • css
    • bootstrap.min.css
    • blog.css
  • js
    • bootstrap.min.js

Now here’s the first code block we’re going to put in functions.php:

// Add scripts and stylesheets
function startwordpress_scripts() {
	wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.6' );
	wp_enqueue_style( 'blog', get_template_directory_uri() . '/css/blog.css' );
	wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.6', true );

add_action( 'wp_enqueue_scripts', 'startwordpress_scripts' );

In order for these to properly be inserted into your theme, <?php wp_head(); ?> needs to be placed before the closing </head> tag, and <?php wp_footer(); ?> before the closing </body> tag.

By common WordPress convention, I’m naming my script after my theme (startwordpress_scripts()). wp_enqueue_style is for inserting CSS, and wp_enqueue_script for JS. After that, the array contains the ID, location of the file, an additional array with required depenedencies (such as jQuery), and the version number.

Now we have jQuery, Bootstrap CSS, Bootstrap JS, and custom CSS being properly loaded into the website.

Enqueue Google Fonts

The function to include the Google Fonts stylesheets is slightly different, based on the dynamic nature of the URL. Here is an example using Open Sans.

// Add Google Fonts
function startwordpress_google_fonts() {
				wp_register_style('OpenSans', 'http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800');
				wp_enqueue_style( 'OpenSans');

add_action('wp_print_styles', 'startwordpress_google_fonts');

Now I have Open Sans by Google Fonts linked in my page.

Fix the WordPress Title

If you’ll notice, we’re currently pulling in the title for the website with this code.

<title><?php echo get_bloginfo( 'name' ); ?></title>

This is not very intuitive – it means that whatever you have set as your website’s title will be the title tag for every page. However, we’re going to want each individual page to show the title of the article first, and also include a reference to the main site title.

Introduced in WordPress 4.1 is the ability to simply have WordPress take care of the title tag in an intuitive way. Simply remove the title tag from your header.php entirely, and in functions.php, add this code block.

// WordPress Titles
add_theme_support( 'title-tag' );

Create Global Custom Fields

Sometimes, you might have custom settings that you want to be able to set globally. An easy example on this page is the social media links on the sidebar.

Right now these links aren’t leading anywhere, but we want to be able to edit it through the admin panel. The source of this code is modified from this Settings API tutorial.

First, we’re going to add a section on the left hand menu called Custom Settings.

// Custom settings
function custom_settings_add_menu() {
  add_menu_page( 'Custom Settings', 'Custom Settings', 'manage_options', 'custom-settings', 'custom_settings_page', null, 99 );
add_action( 'admin_menu', 'custom_settings_add_menu' );

Then we’re going to create a basic page.

// Create Custom Global Settings
function custom_settings_page() { ?>
  <div class="wrap">
    <h1>Custom Settings</h1>
    <form method="post" action="options.php">
           settings_fields( 'section' );
           do_settings_sections( 'theme-options' );      
<?php }

The code contains a form posting to options.php, a section and theme-options, and a submit button.

Now we’re going to create an input field for Twitter.

// Twitter
function setting_twitter() { ?>
  <input type="text" name="twitter" id="twitter" value="<?php echo get_option( 'twitter' ); ?>" />
<?php }

Finally, we’re going to set up the page to show, accept and save the option fields.

function custom_settings_page_setup() {
  add_settings_section( 'section', 'All Settings', null, 'theme-options' );
  add_settings_field( 'twitter', 'Twitter URL', 'setting_twitter', 'theme-options', 'section' );

  register_setting('section', 'twitter');
add_action( 'admin_init', 'custom_settings_page_setup' );

Now I’ve saved my Twitter URL in the field.

For good measure, I’m going to add another example, this time for GitHub.

function setting_github() { ?>
  <input type="text" name="github" id="github" value="<?php echo get_option('github'); ?>" />
<?php }

Now you’ll just duplicate the fields in custom_settings_page_setup.

  add_settings_field( 'twitter', 'Twitter URL', 'setting_twitter', 'theme-options', 'section' );
  add_settings_field( 'github', 'GitHub URL', 'setting_github', 'theme-options', 'section' );
	register_setting( 'section', 'twitter' );
  register_setting( 'section', 'github' );

Now back in sidebar.php, I’m going to change the links from this:

<li><a href="#">GitHub</a></li>
<li><a href="#">Twitter</a></li>

To this:

<li><a href="<?php echo get_option('github'); ?>">GitHub</a></li>
<li><a href="<?php echo get_option('twitter'); ?>">Twitter</a></li>

And now the URLs are being dynamically generated from the custom settings panel!

Featured Image

You might want to have a featured image for each blog post. This functionality is not built into the WordPress core, but is extremely easy to implement. Place this code in your functions.php.

// Support Featured Images
add_theme_support( 'post-thumbnails' );

Now you’ll see an area where you can upload an image on each blog post.

I’m just going to upload something I drew in there for an example. Now, display the image in content-single.php.

<?php if ( has_post_thumbnail() ) {
} ?>

Now you have an image on your individual post pages! If you wanted the thumbnail to show up on on the main blog page as well, you could do something like this on content.php to split the page if a thumbnail is present:

<?php if ( has_post_thumbnail() ) {?>
	<div class="row">
		<div class="col-md-4">
			<?php	the_post_thumbnail('thumbnail'); ?>
		<div class="col-md-6">
			<?php the_excerpt(); ?>
	<?php } else { ?>
	<?php the_excerpt(); ?>
	<?php } ?>

Custom Post Types

One of the most versatile way to extend your WordPress site as a full blown content management system is with custom post types. A custom post type is the same as Posts, except you can add as many of them as you want, and with as much custom functionality as you want.

If you’re interested in using plugins, you can download the Advanced Custom Fields plugin, which will add a great deal of customizability to your theme with little effort.

For now, I’m going to show you how to set up a simple custom post type, and call the post in it’s own loop. There is much more that can be done with custom post types, but that’s a bit more complicated and deserves an article all of its own.

Custom Post Types on the WordPress codex will also give you more insight on some of the possibilities available.

In functions.php, I’m going to create the custom post type called My Custom Post.

// Custom Post Type
function create_my_custom_post() {
	register_post_type( 'my-custom-post',
			'labels' => array(
					'name' => __( 'My Custom Post' ),
					'singular_name' => __( 'My Custom Post' ),
			'public' => true,
			'has_archive' => true,
			'supports' => array(
add_action( 'init', 'create_my_custom_post' );

In the create_my_custom_post(), I’ve created a post called My Custom Post with a slug of my-custom-post. If my original URL was example.com, the custom post type would appear at example.com/my-custom-post.

In supports, you can see what I’m adding – title, editor, thumbnail, and custom fields. These translate to the fields on the back end that will be available.

  • title is the title field that I call with <?php the_title(); ?>.
  • editor is the content editing area that I call with <?php the_content(); ?>.
  • thumbnail is the featured image that I call with <?php the_post_thumbnail(); ?>.
  • custom-fields are custom fields that I can add in and call later.

I’ve decided I’m going to make a new page for the custom post to loop in. I created a page called Custom, which will appear at example.com/custom. Right now, my page is pulling from page.php, like all the other pages.

I’m going to create page-custom.php, and copy the code over from page.php. According to the WordPress template hierarchy, a page-name.php will override page.php.

The original loop we used looked like this:

if ( have_posts() ) : while ( have_posts() ) : the_post();
	// Contents of the Loop
endwhile; endif; 

A custom post type loop will look like this:

$custom_query = new WP_Query( $args );
while ($custom_query->have_posts()) : $custom_query->the_post();
  // Contents of the custom Loop

Note that this only a while, and does not have an if or endif.

I’ll have to define the $args or arguments, before the loop.

$args =  array( 
	'post_type' => 'my-custom-post',
	'orderby' => 'menu_order',
	'order' => 'ASC'

Here I’m defining the post type as my-custom-post, and ordering the posts in ascending order.

So here’s the entire code for page-custom.php.

<?php get_header(); ?>

	<div class="row">
		<div class="col-sm-12">

				$args =  array( 
					'post_type' => 'my-custom-post',
					'orderby' => 'menu_order',
					'order' => 'ASC'
				 $custom_query = new WP_Query( $args );
            while ($custom_query->have_posts()) : $custom_query->the_post(); ?>

				<div class="blog-post">
					<h2 class="blog-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
					<?php the_excerpt(); ?>

				<?php endwhile; ?>
		</div> <!-- /.col -->
	</div> <!-- /.row -->

	<?php get_footer(); ?>

Now example.com/custom will only pull in posts from the custom post type we created. Right now, the custom post type is set up to only do things that the normal posts can do, but the more you fall down the rabbit hole, the more possibilities you discover. If this isn’t working, make sure you’ve successfully updated permalinks.


We covered a lot of ground in this article; you should now be able to…

  • Create individual pages for blog posts
  • Add pagination to a blog
  • Add comments to a blog
  • Add WordPress functions
  • Enqueue scripts and stylesheets properly
  • Have a proper page title
  • Create custom global settings
  • Create a custom post type

All the source code is on GitHub as always. You can download the code and upload it into your themes folder and see it in action. I might set up a demo if there’s any interest in that.

There is much more that custom post types can do – and much more that WordPress can do, as well. I haven’t touched on the theme customizer, which is the most current way of creating themes.

I plan to continue this WordPress series and expand upon custom post types and what they can do. For now, I hope you learned something new, and of course, please feel free to reach out if I made any mistakes or errors or included any wrong or outdated information.

View on GitHub

Part Three

Update 8/11/16

In part three, I discuss how to add custom fields and meta boxes to a post!

Go to Part 3


Hi, my name is Tania Rascia. I've turned down every advertiser, sponsored post, and affiliate who has contacted me. I write free resources that have helped thousands of people successfully transition into a web development career.

My committment is to no bullshit, no sponsored posts, no ads, and no paywalls. If you enjoy my content, please consider supporting what I do.

Support my work

Write a response

Your email address will not be published.

All code will be displayed literally.


  • Shadi says:

    when i wrote the the function code in single.php the comments system worked automatically without having to make comments.php file at all. why is that?

  • Muhammad says:

    Did anyone notice that example.com/custom works without creating "page-custom.php"
    This means page-custom.php is useless, No need to create that file as it takes posts from content.php not from page.php

  • James Velasquez says:

    I feel for writers and the work they have to do for quality writing. You have obviously done a lot of work on this. I don't normally comment on articles, but I have to on this one. Your article is very well-written with a lot of useful, original and bold.

  • phil says:

    Hi Tania can you make more tutorials on using theme customiser for creating themes. Thanks!!

    Nice work

  • Tadeusz says:


    I struggled with the pagination issue, where you need to put

    <ul class="pager">
    <li><?php next_posts_link( 'Previous' ); ?></li>
    <li><?php previous_posts_link( 'Next' ); ?></li>

    between the enwhile; and endif;

    The solution calls for getting the html code out of the main <?php ?>, which holds the loop.

    This is what worked for me:


    <?php if ( have_posts() ) : ?>

    <?php while ( have_posts() ) : the_post();
    get_template_part( 'content', get_post_format() );
    endwhile; ?>

    <ul class="pager">
    <li><?php next_posts_link( 'Previous' ); ?></li>
    <li><?php previous_posts_link( 'Next' ); ?></li>

    <?php endif; ?>

    I hope it works for you.

    Btw, thank you for the excellent material!!

  • Kristov says:

    Hello Tania, still the best. I saw your Github page too.

    Did you try Custom functions? Better or worse than theme functions.php


  • Rohit Goyal says:

    I have linked my main.js through 'wp_enqueue_script' in function.php but it is working only on front-page.php but not working on other pages.

  • Adrian says:

    In the startwordpress theme, Widgets(Dashboard >> Appearance >> Customize") disappear.
    How can I view Widgets or create "Search" separately?

  • mohammad says:

    tnx Tania , u r very good teacher

  • Alexander biscajin says:

    Hey Tania, Thank you for sharing this tutorial. I am definitely going to share it with my colleagues. I just want to know can you help me out in pagination function code as I have seen the tutorial for pagination and I am working on it step by step but I am having issues in pagination function. This is the reference (https://www.wpblog.com/use-wp_query-to-create-pagination/) that I have used and the code in which I am having issue is the function of pagination.

    <?php if (function_exists('pagination')) {
    } ?>

  • franchise opportunities in nj says:

    Currently it looks like WordPress is the best blogging platform available right now. (from what I've read) Is that what you're using on your blog?


  • Dan Glyde Chavez says:

    Hi could you reply a more step by step tutorial about that pagination list? I get errors when adding it between endif and elsewhere

  • Maz says:

    Outstanding, i have no words to describe how much i’m grateful to you for sharing these three articles. I developed for years w/h a bunch of tecnologies and as you may know, it’s fairly easy feel lost once you have to re-use one of your “old tecnologies”.

    This is exactly what i was looking for, a series of article to quickly get started w/h WordPress from beginner to intermediate, next step: WordPress REST API.

    Thank you again, keep up the excellent work!

  • Daisyallie says:

    Thanks for this information. Really a nice blog.

  • Sean says:


    I’m having an issue getting the pagination working. Everytime I add the code and reload my page I get a Parse error: syntax error, unexpected.

    Is it possible for you to show me what the index.php is supposed to look like when correct?

  • Ndiade Mamadou says:

    The more i read through these awesome tuts, the happier i am for more discovering things about wordpress

  • Ever Atilano says:

    Hello Tania,
    thanks for the tutorial but I have a question. It is possible to add the search functionality to our template?

  • Emilia says:

    It’s a great tutorial so far, so thank you for that, however, I have been stuck at the pagination styling for a few hours (it was showing the bullet points but not the button)
    And I was unhappy with just copying and pasting the old bootstrap css (using 4.0.0 atm) because in future I wouldnt have that fallback.
    I inspected the buttons on the bootstrap template that you linked and they had styling for a span, so I popped that into blog.css and it appears to have fixed it.
    I don’t know if that will affect anything else in future but if anyone else gets that issue, this might help them.
    I have linked a screenie since I can see from other comments that code gets deleted

  • Pierre Simard says:

    Hi Tania,

    2 issues here.

    1- I’m getting “Previous page” only on the pagination nav of the blog page… Seems like WP is giving me the last page of the blog at first… Makes my blog kind of backwards.

    2- There’s an empty at the first page of the blog. Cause there’s no “next” page… Related to issue #1.

    Did you see this elsewhere?

    Thanks and regards 🙂

  • Rob says:

    I see that there are some comments about the functions.php. I was struggling myself but got it fixed so I thought I’d share it here.

    In the function.php you created a script e.g. “startwordpress_script()” and that you need to enter in the header and footer.php. If you later on add more functions/scripts in function.php with different names you refer to them the same way, from the other files by calling their name.

    So in header.php just below the php header line you add a new line “” and in the footer you do the same just below the footer.
    That’s all..

    • Rob says:

      seems my comments are not posted correctly… the line you need to post below heard and footer php line is:

      (adding extra spaces, you understand they don’t belong there, right?)

  • Rob says:

    I see some have issue with the pagination.. just remember to open en close correclty.. so after get_pst_format you need to close. open again before endwhile and close behind it and the same with endif.. it works fine after that. good luck

  • Bruce Perez says:

    Hi Tania Thank you for this wonderful tutorial

    im in the last part on this part 2 tutorial

    when i type http://localhost/wordpressnewnew/custom i get directed to http://localhost/wordpressnewnew/my-custom-post/custom-post-title/

    am i in the right track? as i landed on this path i noticed that my h2 is not wrapped with anchor tag
    and the permalink seems to not include custom

    while when i only go to http://localhost/wordpressnewnew/my-custom-post

    everythings ok except for the permalink to include custom

    i back read some comments with same issue about the permalinks
    as you suggested to try refreshing the permalink in the setting

    so i tried to navigate my self to the permalink setting and save
    am i doing it right?

    thanks in advance.

    • Bruce Perez says:

      oh sorry the problem i stated lately is solved

      just forgot to add a new page called Custom in the dashboard

      i only added new file Custom to my texteditor 😀

      thank you for this tutorial ill keep going to the 3rd part

      • Tormod Smith says:

        Great set of Tutorials – I had been struggling with an existing theme, I was debating on whether to use a node server templating engine and word press API. These tutorials though have shown me how to customise my own theme through php, which I think is possibly the simplest solution for a blog page. Note, got stuck on the custom page part as well – adding a custom page to the dashboard solved this.

  • Danny says:

    Great tutorial! My theme was broken after moving my stylesheet (style.css) to the css folder.
    Isn’t it supposed to be in the root folder? It was working again after moving it back to the root folder, but I had to change the wp_enqueue_style arguments (without ‘/css/’) ofcourse.

  • Rob says:

    One more question. How do you really disable comments?

    I was moving on and instead of implementing comments inline with each blog post I was thinking of doing something different. First, I thought I would try to use the dashboard to disable comments but is it not working. I have uncheck the box in the Discussions setting to allow comments and saved the settings but the comments box still appears after each blog post.

    How do you really get rid if this?


  • Rob says:

    Tania, Thanks for the tutorial. I always wonder why some people are so generous with their time. I am very grateful for this.

    I did run into an odd issue. I got as far as pagination and things are not working. When I click on Previous Page I get “The requested URL /wp/page/2/ was not found on this server.” And selecting Sample Page off the main menu gave “The requested URL /wp/sample-page/ was not found on this server.”

    I thought it was maybe a typo but I checked carefully and even downloaded your source from Git. Still had the error

    I am new to WordPress. But since this looks like a URL construction error. I did a triple check on permalink settings. They are postname for sure.

    Just on a hunch I set permalinks to Plain and guess what. The error went away.

    Any idea what is going on?

  • Michael J. Wiebe says:

    Thank you very much for putting this together! Its a fantastic guide.

  • Dugi says:

    Hello, this code doesn’t working. I don’t know am I do something wrong. Can you help please?

  • Kate says:

    I’m stuck on “Enqueue Scripts and Stylesheets”
    What goes into bootstrap.min.css and boostrap.min.js? Is there a link for a download? And what happens to the jquery.min.js reference?

    • Anonymous says:

      same situation here.
      BTW this blog is just fantastic! Thanks!

    • Alex says:

      Hi Kate, WP has it own jquery already registered.

      So you dont need a link for it, and only to declare.

      If you want to set your own version and wp default , you can:

      function changejquery_include_custom_jquery() {

      wp_enqueue_script(‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js’, array(), null, true);

      add_action(‘wp_enqueue_scripts’, ‘changejquery_include_custom_jquery’);

  • Berkan says:

    first of all grat tutorial.
    i just have one problem if i try to open the post “custom post title”
    it doesnt show me the content of it instead it just shows a blank page.

  • Alisha says:

    I’ve now gone through parts 1 and 2 of this tutorial. I really like your writing style – very easy to follow (for the most part). I did get a little stuck on the Custom Post Type part though and I really don’t know how to proceed. You can see all the custom posts looped on my Custom page, but when I click on their titles, they bring me to “Page Not Found”. My regular posts don’t do that, since I have single.php to handle them. I’m not clear on where, in this code for the custom post type, it’s supposed to be using single.php?