• Since wp_list_categories is defined in the category-template.php file in the wp-includes folder, could you please instruct what code to add/delete and where to do so in the category-template.php file in order to exclude listing of child category posts from parent list of posts.

    All I want to do is exclude subcategories from 3 main categories.
    At Bibliography page –
    http://lifegivingspring.info/bibliography/faith
    Click on ‘Ancient Faith’ parent category in widget on right; then on ‘Home’ child category under that.
    All the same post entries are pulled up each time, but all posts are in the ‘Home’ child category, not in the ‘Ancient Faith’ parent category.

    Bibliography page has no code to create category list. That code is coming from the plugin, and there is no code in plugin php file that resembles wp_list categories, so the plugin must be pulling that from a core file.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Don’t show posts from child category.

    <?php
    $current_cat = intval( get_query_var('cat') );
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args=array(
      'category__in' => array($current_cat),
      'paged' => $paged,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    query_posts($args);
    
    ?>

    [code edited]

    Thread Starter dstall

    (@dstall)

    Here is code for wp_list_categories from WP core file, category-template.php file.
    Where should code you’re suggesting be added?
    Should any code be replaced (deleted) by it?

    [moderated please put large code segments in a paste bin such as wordpress.pastebin.com and report the link back here]

    Thread Starter dstall

    (@dstall)

    I’m using a category plugin; I can’t get categories to list with wp code but they list fine with plugin.

    I do not want to make a category template. That defeats the purpose of having a plugin, unless you can be specific and show me what code to put in template that will effect plugin.

    The links you provide are general and not specific to my situation. I don’t know enough about code to follow what is being explained in the links and interpret it to my situation.

    Not much more that I can add if you don’t want to use a category template and I’m not sure what the plugin is doing that you are talking about.

    Thread Starter dstall

    (@dstall)

    Code you provided doesn’t work as intended.
    See – http://lifegivingspring.info/bibliography

    At bottom of right sidebar is ‘Categories’ list with ‘About LGS’ parent category, and ‘Case Study’ child category.
    Click on ‘Case Study’ and it only lists post entry for that child category. But click on ‘About LGS’ and it lists post entries for both that parent category and its child category (‘Case Study’).

    Category list entitled ‘Page | Bibliography’ (above list produced with your code) in right sidebar is from AVH Extended Categories plugin. See –
    http://wordpress.org/extend/plugins/extended-categories-widget/

    What code will reproduce what is in that Page | Bibliography category list, as well as exclude list of posts of child categories from parent categories?

    Click on ‘Home’ child category under ‘Ancient Faith’ parent category and you will see list of 10 entries.
    Your code does not list these entries, presumably because it won’t list posts that are private using WP Sentry plugin. See –
    http://wordpress.org/extend/plugins/wp-sentry/

    I have ordered categories using Category Order plugin
    http://wordpress.org/extend/plugins/order-categories/

    And sorted posts returned from categories with Sort Categories By Title plugin
    http://www.mikesmullin.com/wordpress_plugins/wordpress-plugin-sort-categories-by-title/

    BTW I had to precede your code with php wp_listcategories( $args ), then close that code after your code to get your code to work.

    I could have placed that code directly on my bibliography.php page as easily as create a template for it then call the template on the bibliography page.
    See –
    http://codex.wordpress.org/Template_Tags/wp_list_categories

    Thanks for the heads-up — I’ve added the <?php to that code and changed it to ‘category__in’

    Thread Starter dstall

    (@dstall)

    Michael,
    Your code already includes ‘category_in’, and doesn’t work with or without <?php before it, so I have no idea why or what you’re trying to say.

    As I’ve tried to suggest before, this feature of excluding child post entries from parent list of post entries should be addressed as a function in category-template.php file (in wp-includes folder).

    Could you please provide the needed code for modifying category-template.php, or refer this issue to someone who can.

    Thread Starter dstall

    (@dstall)

    Why didn’t you reply that you had changed code shown in your previous post to ‘category_in’?!

    I looked at your previous post and it was already there, then discovered in my categories template, that the code there was different from your post, so you must have changed your previous post, which is VERY confusing! not just for me but anyone who my read this thread.

    So what code do you include with the code you’re providing for it to have any effect???

    Your code still does NOTHING without being including in php for wp_listcategories( $args ) as I stated previously, and even when included with it, still returns the child category post listing with the parent post listing.

    I did note that I edited that code, but I apologize for complicating the matter.

    Someone else might answer your question because I’m confused by what you need so better to get a different perspective.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to display parent category posts without child category posts?’ is closed to new replies.