Forums

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

  1. nottinghamjazz
    Member
    Posted 10 months 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
    Member
    Posted 10 months 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.
    http://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category

  3. roya khosravi
    Member
    Posted 10 months 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
    Member
    Posted 10 months 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
    Member
    Posted 2 months ago #

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

    Many thanks!

Reply

You must log in to post.

About this Topic

Tags

No tags yet.