WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Theme: Premium News] Exclude a category from a section (7 posts)

  1. FlanNataAdmin
    Member
    Posted 11 months ago #

    Hi all,

    first of all, my website is http://flanynata.com/

    I'm trying to exclude the category 'Breves' from the section of short news at the bottom of the page. I've been trying this changing the default.php but I couldn't get it.

    `<div class="box">

    <?php

    $the_query = new WP_Query('cat=-'. $GLOBALS[ex_feat] . ',-' . $GLOBALS[ex_vid] . ',-' . $GLOBALS[ex_breves] . '&showposts=' . get_option('woo_other_entries') . '&orderby=post_date&order=desc');

    $counter = 0; $counter2 = 0;

    while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
    ?>

    I thought that adding $GLOBALS[ex_breves] to the other two by default exclude categories I would get this but for some reason that doesn't work.

    Any ideas to fix it?

    Thanks!

  2. Sphinx Sword
    Member
    Posted 11 months ago #

    You need to find the ID of the category "Breves" and then add "cat=-X" where "X" is the ID of "Breves". So if "Breves" has an id of "3", Your code would look like this:

    $the_query = new WP_Query('cat=-'. $GLOBALS[ex_feat] . ',-' . $GLOBALS[ex_vid] . ',-' . $GLOBALS[ex_breves] . '&showposts=' . get_option('woo_other_entries') . '&orderby=post_date&order=desc&cat=-3');

    If you need to exclude multiple categories, you would seperate the ids with commas like this: cat=-X,-Y,-Z

  3. Sphinx Sword
    Member
    Posted 11 months ago #

    Oh and remove this:
    ,-' . $GLOBALS[ex_breves] . '

  4. FlanNataAdmin
    Member
    Posted 11 months ago #

    Thank you very much. It would have been impossible without your help. Thanks a lot!

  5. FlanNataAdmin
    Member
    Posted 11 months ago #

    At this point you have realised that i'm a novice in that. Even I thought that the problem was resolved it isn't because i don't know what exactly ID means... it probably is a basic concept but i don't know how to find it...

    So... could you say me what is ID and how could I find it? Thanks and sorry!

  6. Sphinx Sword
    Member
    Posted 11 months ago #

    To get the ID of a category, in the dashboard's sidebar go to "Posts" then click on "Categories" from the list that appears when you hover over "Posts". If you use Firefox, when you hover over the category link, in the lower left of the window you see the url of what you are hovering over. Something like:

    http://www.somewebsite.com/wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=9&post_type=post

    Toward the end of that link you will see "ID=" and then a number. That number is the ID of the category. Each category has a unique ID. In the url above the ID is 9.

    If you use Safari you need to make sure the "Status Bar" is visible to see the url at the bottom. You can turn the "Status Bar" on by going under "View" in the menu area.

  7. FlanNataAdmin
    Member
    Posted 11 months ago #

    Thank you so much, you really help me with this problem. I'm really grateful!!

    Best regards

Reply

You must log in to post.

About this Topic