• Resolved FlanNataAdmin

    (@flannataadmin)


    Hi all,

    first of all, my website is https://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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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

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

    Thread Starter FlanNataAdmin

    (@flannataadmin)

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

    Thread Starter FlanNataAdmin

    (@flannataadmin)

    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!

    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:

    https://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.

    Thread Starter FlanNataAdmin

    (@flannataadmin)

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

    Best regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Theme: Premium News] Exclude a category from a section’ is closed to new replies.