[resolved] How to add new posts but prevent them appearing on blog homepage (5 posts)

  1. nottinghamjazz
    Posted 7 years ago #

    I have a blog for my band.

    I also want to add non-band related posts to my blog (to drive more viewers to my site) but I don't want those unrelated posts to appear on the homepage of the blog. When a user views my blog I want only the relevant band posts to appear on the homepage.

    How do I suppress some posts from being added automatically to the top of my blog homepage, but still make those posts indexable (and hence googleable) ?

    Does this question make sense? Thanks

  2. asfodel
    Posted 7 years ago #

    You can use categories to accomplish this. Use a separate category for the non-band related posts and then edit the code to exclude that category from the main page.

  3. roya khosravi
    Posted 7 years ago #

    to display posts from all categories except category_id 18:
    in /wp-content/themes/your theme/index.php

    <?php if (have_posts()) : ?>
    <?php if (is_home()) query_posts("cat=-18"); ?>
    <?php while (have_posts()) : the_post(); ?>
  4. nottinghamjazz
    Posted 7 years ago #

    Wow that was super smart. I found all I needed to add was:

    <?php if (is_home()) query_posts("cat=-5"); ?>

    beneath the <?php if (have_posts()) : ?> and before the <?php while (have_posts()) : the_post(); ?> lines at the top of my default theme index.php

    Thank you for your help!

  5. samandiriel
    Posted 6 years ago #

    Good trick, just what I was looking for to prevent posts with video from appearing on my main page!

    Many thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.