• I want to set a single category to show up on the home page and only have the posts to the other categories show up when a user goes directly to that category.
    Has anyone done this? If not, can someone point me in the right direction to do it myself?
    Ian

Viewing 5 replies - 16 through 20 (of 20 total)
  • Why hasn’t this been coded into the latest WP, is there a definitive way of doing this yet? It was one of the first things I went looking for.

    Brian

    Yes there is. Use home.php for your front page. Then use query post. Simple.

    Hey Root, thanks for quick reply but…….

    I just migrated from Drupal yesterday – I’m still not 100% with WP, could you elucidate for me please?

    Well on another thread we are just getting into running the loop twice. Fortunately that is not necessary here. I would save index.php as home.php. That will load by default on the front page only . Then edit the loop.
    It needs to be altered from returning all posts to returning a single post in a single cat. The WP tag query post is tailor made. Most of the other stuff could be deleted.

    Here is the top of my “home.php”, which now only displays posts in the “Announcements” category:

    1 <?php get_header(); ?>
    2
    3 <div id=”content” class=”narrowcolumn”>
    4
    5 <?php if (have_posts()) : ?>
    6
    7 <?php while (have_posts()) : the_post(); ?>
    8
    9 <?php
    10 if( !preg_match( ‘/announcements/i’, get_the_category_list() ) )
    11 {
    12 continue;
    13 }
    14 ?>

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Can I set a *single* default Category on homepage?’ is closed to new replies.