• Newbie here!!!!!!!!!
    I need help and need it bad. I would like to know how I to exclude some Categories from home page.
    If I need to add some code, please give me the codes and tell me exactly where to insert the codes.
    But point and click will be awesome if any exist.
    Thanks in advance

Viewing 12 replies - 1 through 12 (of 12 total)
  • You will need to create a custom query in your theme’s index.php template file. See:
    http://codex.wordpress.org/Function_Reference/query_posts
    http://codex.wordpress.org/Function_Reference/WP_Query

    Thread Starter orjense

    (@orjense)

    Thanks for the help. I added the code below in my index.php and it didn’t work for me, I’m sure I did something wrong. Is there any particular point
    at index.php that i need to insert the code?
    Thanks again

    if ( is_home() ) {
    query_posts( ‘cat=-3,-4,-5,-6,-7,-8,-9’ );
    }
    ?>

    Is there any particular point at index.php that i need to insert the code?

    Before the start of the Loop.

    Thread Starter orjense

    (@orjense)

    Esmi,
    Thank you so very much for all your help, really appreciate it.
    What does the start of the loop look like, what code should I look for to know where the loop start?
    Do forgive my kindergarten questions, I’m so new at this and need help here and there.

    Thank again.

    Try reading http://codex.wordpress.org/The_Loop It will pay dividends in the long run if you can learn how to use this all-important core element of any WordPress page.

    you could help us helping in more detail when you post the name of your theme.

    the loop usually starts with:
    if( have_posts() ) :
    or just with:
    while( have_posts() ) :
    or very similar.

    http://codex.wordpress.org/The_Loop

    Thread Starter orjense

    (@orjense)

    Alchmyth,
    I’m using AndroidPhone theme by NewWpThemes.com
    Regards

    Thread Starter orjense

    (@orjense)

    This is what my index.php look like

    [Code moderated as per the Forum Rules. Please use the pastebin]

    have a look into index.php;

    line 6 ( <?php if (have_posts()) : ?> ) is the start of the loop;

    add your code just before that line:

    <?php
    if ( is_home() ) {
    query_posts( 'cat=-3,-4,-5,-6,-7,-8,-9' );
    }
    ?>

    to avoid problems with pagination, expand the code, following the example from:
    http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note:

    <?php
    if ( is_home() ) {
    global $query_string;
    query_posts( $query_string.'&cat=-3,-4,-5,-6,-7,-8,-9' );
    }
    ?>

    Oh wow. I think this is my situation exactly.

    I am using a plugin to display printable recipes (Easy Recipe) that requires each recipe to be a separate post. I also have a straightforward blog on the site, and I don’t want the recipe posts to show on the “Blog” page as posts.
    I have 2 categories: Recipes and Blog. I assume that there is a relatively easy way to exclude the Recipes category from displaying in the Blog page.

    If my “blog” is not the home page, do I still add the code to the index.php or to single.php, or somewhere else?
    Thanks so much…

    Got it! Thanks esmi.

    Thread Starter orjense

    (@orjense)

    alchymyth-
    Thanks a lot for pointing me to the right direction. Everything works like a charm. Thank.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Excluding some Category from Home Page’ is closed to new replies.