Problem showing blog posts

Hi , Ive built a theme up from scratch, and have got the majority of it working , however I’ve hit a wall getting the blog posts to display?, i thought i had everything ok but it seems not. as im teaching myself , makes things a little harder! so i was wondering if someone could explain to me when writing a theme from scratch , how to get the blog to display , just the standard process what files etc , and i can check what I’ve done against that and see where I’ve gone wrong…


Hi jnrDeveloper. Welcome to the forums. :slight_smile:

I’m not very exerienced at this, but what I’ve done in the past is open up the default WP theme and compare that code to your own. You can easily see what code is being used to display blog posts.

Hi ralph, Thanks.

I managed to figure out what id done wrong by pretty much that method , i reverted back to a theme i knew worked and systematically checked through the pages of code. turns out it was relating to something in index.php!

Hi jnrDeveloper,

Index,php is often used as default page in WP. Since you are trying to display blog post, your theme (assuming you haven’t created any templates) will use index.php, if you however wanted to use a different page template you can do so by adding /* Template Name: Blog Post */ before the header hook on the page.

You can utilize this feature if you wanted to use different layouts for different pages. Let me know if you have more questions, and I’ll help you :slight_smile:

Hi shadir41…

thanks for your help… i seem to have that part working now and understand why … my next question is, when adding a new page via the dashboard in the new theme , it doesn’t display , but obviously does in the standard themes , which bits make that work? the navigation is built in the HTML , im gonna need to figure that out too , heh it not easy teaching yourself , you go so far and hit the wall :smiley:

Ok, here’s what you need to know.

For Pages, WP uses Page.php. Create a new page, copy the index.php inside it and name it page.php.
Navigation, you should use wp_menu function. Here’s the codex

basically you need to enter this on your functions.php

function register_my_menu() {
  register_nav_menu('header-menu',__( 'Header Menu' ));
add_action( 'init', 'register_my_menu' );

And add this into your header, where navigation supposed to be

<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>

create a new navigation on Appearance > Menu

Remember, when you’re stuck look for codex. It’s your bestfriend :slight_smile:

that’s awesome , thank you!! will keep me busy for the next couple of days … really appreciate the help … Thanks!!