Forums

[resolved] Only certain categories for main page. (6 posts)

  1. substandardtim
    Member
    Posted 3 years ago #

    I've been thinking about switching to WordPress from blogger and when I do I want to have the site set up a certain way.

    Say for example I am making a site about farm animals and my post categories will be: site updates, chickens, geese, and ducks. However, I only want posts in the 'site updates' category to show on the main page. Any posts made in other categories would be accessed by clicking on the link for those categories.

    Is this possible? Is there a plugin for such a thing? Could I somehow just edit the main page php file to show only a selected category?

    Thanks in advance for any help.
    -substandardtim

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    Assuming the 'site updates' category ID is 7, and if you are using the WordPress Default Theme, you would just change the wp-content/themes/default/index.php:

    from:

    <?php if (have_posts()) : ?>

    to

    <?php
    query_posts($query_string . '&cat=-7);
    if (have_posts()) : ?>

    Also the Custom Query String Reloaded and the
    Advanced Category Excluder plugins could do this.

  3. substandardtim
    Member
    Posted 3 years ago #

    Thanks for the help. I had actually tried the advanced category excluder plugin before i posted this but couldn't really see what it was supposed to do for me once I had activated it but I am a newbie with wordpress.

  4. substandardtim
    Member
    Posted 3 years ago #

    Having actually tried your code now there are a small change that should be made.

    It should actually be query_posts($query_string . '&cat=7');

    The difference being that using the minus sign in front of the 7 actually removes that category from showing, eliminating the minus sign causes this code to do exactly what I wanted it to and only show that category. Just wanted to post this in case someone else searches for the same issue.

    Thank you again, you've helped confirm in my mind that I will in fact be signing off of blogger.

  5. MichaelH
    Volunteer
    Posted 3 years ago #

    You will want to understand the Template Hierarchy and Category Templates if you are going to be customizing things to any extent. Also review WordPress Semantics.

  6. mikey1
    Member
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic