Support » Themes and Templates » Best practice for blog tab setup

  • I might already know the answer to my own question, but I just wanted to talk through this and have some conversation… I notice different themes are programmed in so many different ways. Let’s say I have a website that is going to have several static pages on the navigation and one blog link. What’s the best way for that to be set up? With a blog page placeholder using a custom blog template, or to set the static home page and blog pages in the Reading settings?

    My guess would be that you could set up a static blog page if you want to be able to put some introductory content before the blog listings, but if you just need a standard blog archive page, you can just use the Reading settings and add a navigation link in the menu.

    Which is a better way? I’m a semi-beginner theme coder and just curious as to what others do.

Viewing 1 replies (of 1 total)
  • I usually create a page called ‘Home’ and set it as a static home page in the Reading settings, then create a page titled blog and set that as ‘blog’ in the reading settings.

    The easiest way to add some introductory content to that page would probably be to add it as a custom field on index.php (usually) above the loop, with a php conditional so that it only shows up on the blog page, something like this:

    <?php if (is_home()) { ?>
    <?php echo get_post_meta($post->ID, 'intro', true); ?>
    <?php } ?>

    Then you’d add a custom field to your ‘Blog’ page titled ‘intro’ and add your introductory content in the ‘value’ section.

    There are lots of other ways to do this though I’m sure.

    * is_home is the conditional for the blog page, whatever the page is called, not quite sure why though 😉

    Conditionals are super useful when building themes, you can learn more about them here:

Viewing 1 replies (of 1 total)
  • The topic ‘Best practice for blog tab setup’ is closed to new replies.