Forums

Exclude Child Categories (3 posts)

  1. magbiz
    Member
    Posted 2 years ago #

    Hi,
    I have a little prob ...
    I use WP for my online magazine and have a few modifications in my theme.

    My Header shows the latest Headline from 2 Main Categories.

    <?php $do_not_duplicate[] = $post->ID; ?>
    <?php $my_query = new WP_Query('cat=1,35,38,39&showposts=1'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID; ?>

    Thats works without any problems.
    Now I have add an Child Category to the Category "Business" (cat Id 1) and now he shows me also the last entry from the Child Cat. But I don´t understand why ...
    I just want the latest entries from the main categories - Business 1 (german), 35 (english) and Paparazzi 38 (german), 39 (english) - I use the WPML Plugin also ...

    Did anybody has an tip for me?

    Cheers
    Torsten

  2. Edward Caissie
    Member
    Posted 2 years ago #

    Find the category ID for the child category ... then edit your $my_query to exclude it. For example, the child category id is #100

    <?php $my_query = new WP_Query('cat=1,35,38,39,-100&showposts=1'); ?>

    The "-" (minus) sign should exclude the category ID.

  3. magbiz
    Member
    Posted 2 years ago #

    Great cais ... that´s works for me ...

    Thank you so much ....

    Cheers
    Torsten

Topic Closed

This topic has been closed to new replies.

About this Topic