WordPress.org

Ready to get started?Download WordPress

Forums

How to exclude certain posts from homepage (not whole categories) (9 posts)

  1. theweddinggirl
    Member
    Posted 4 years ago #

    I was wondering if someone could help me....

    I want to be able to pick and choose which posts show up on the homepage, I do not want to exclude whole categories from the home page, but sometimes I will post certain things that I do not want on the homepage, I just want them to show up in the category.

    All I can find on here is advice on excluding whole categories, nothing on being able to select on a post by post basis. I would have though there would be a simple tick box when you write each post that would say something like 'do you want this to show up on the homepage?'

    Is there a plugin that does this or some code that I can write in to each post??

  2. stvwlf
    Member
    Posted 4 years ago #

    Your best bet may be to use a static page as your homepage. Create a category "homepage" and assign posts to it that you want on the homepage. Only posts you assign to category homepage will then appear on the homepage. (Take note of what the category ID for that new category is.)

    Create a page in the WordPress page editor, call it Home.
    In admin / settings / reading, set that page to be your static home page.

    In page.php - add a query_posts

    The WordPress loop starts like this

    <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>

    put this code before the WordPress loop

    <?php if(is_front_page()) {
     <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
          query_posts("cat=6&paged=$paged"); ?>
           // where 6 represents cat ID of homepage category
    } ?>

    That will cause only posts assigned to homepage to display on the page. You can assign posts to more than 1 category of course.

  3. theweddinggirl
    Member
    Posted 4 years ago #

    Thanks for your suggestion but I thought it was impossible to post to static page? and also unfortunately this won't really work with my theme as it automatically make the homepage the homepage and puts a tab at the top called homepage where people can click back to the homepage if they are on another page, it seems like this can not be changed.

    Is there really no simple way to actually just stop certain post from showing up on the homepage? I would have though a lot of people would want to be able to do this.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    I thought it was impossible to post to static page

    Not if you use the code that stvwlf suggested.

    this won't really work with my theme as it automatically make the homepage the homepage and puts a tab at the top called homepage

    Should be solved by setting your new page to be your static home page via Admin/Settings/Reading.

    And, yes, this is the simplest way to achieve what you want.

  5. stvwlf
    Member
    Posted 4 years ago #

    puts a tab at the top called homepage where people can click back to the homepage if they are on another page, it seems like this can not be changed.

    WP itself may redirect clicks to that tab to your revised homepage. If not its easy enough to make a small code change to direct to whatever page you choose.

    It is easy to exclude a category(s) from appearing on the homepage. It is not so easy to exclude individual posts.

    If you think about it, what I suggested you do is the exact same thing you want to do, only in reverse. You want to EXCLUDE posts from the homepage, this method makes you INCLUDE posts on the homepage. Its the same thing. Yes, it will take you ten extra seconds per post to click the Homepage category box, but you will get in the habit of doing that soon enough.

  6. stvwlf
    Member
    Posted 4 years ago #

    I thought it was impossible to post to static page

    What we are doing here is using a static page as a vehicle, a stand-in posts page. No content from the static page itself will appear on the page, only the posts in the category designated in the query_posts. We are overriding the default WP behavior for pages and displaying specific classes of posts on a static page. This is part of the power and flexibility built into WP.

    By the way, what you want to do does make sense, in the way you want to do it. But unfortunately that's not built into WP so we have to simulate that behavior with the tools we have available.

    You might want to go to the appropriate forum and submit a request for adding functionality to WP in future releases - that is where many new features come from - from user requests.

  7. theweddinggirl
    Member
    Posted 4 years ago #

    Thanks so much for your advise. But amazingly I have just found a plugin that does exactly what I wanted, it's lets you pick and choose which post go on the home page with a simple tick box when you edit your post. It is FANTASTIC and I hope that lots of people find it useful, it is called WP Low Profiler

    http://wordpress.org/extend/plugins/wp-low-profiler/

    Thanks again for everyone's help!!

  8. Ryan S
    Member
    Posted 4 years ago #

    Check this:

    http://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category

    I hope this can drive you in right direction...

  9. gariben
    Member
    Posted 4 years ago #

    Plugins looks good but unfortunately for my themes.. all of the posts were hidden from reader when activating the plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.