Forums

How to play with categories? (6 posts)

  1. xrundel1
    Member
    Posted 4 months ago #

    I am looking for help/advice for two questions.

    1. How to show on category list only posts that assigned to that particular category. Usually when you click category link it show posts from all sub-categories as well.

    For example: top-level category movies, will show ALL movies from sub-categories like horror, comedy, drama, etc in order it was posted.

    Sub-category "horror" divided for years like sub-categories 1940, 1950 but on list it will show all years that in sub-categories.
    Is it possible to exclude sub-categories from being show in top-level?

    2. Settings for how many posts shows on one category page are standard and working same for all categories.
    Is it possible to specify how many posts show in particular category?

    I think those questions are important when using WP as CMS. For instance - I need in top category only one post with introduction article, all other post are in sub-categories.

    Any help and advices appreciated!!!

  2. xrundel1
    Member
    Posted 4 months ago #

    Nobody? :(

  3. xrundel1
    Member
    Posted 4 months ago #

    Sorry for keeping it up, but I really, really need solution...

  4. KentonWebDesign
    Member
    Posted 4 months ago #

    Hi

    Hope this helps, you can display content from only the parent category without displaying other subcategory content or posts belonging to them by doing this;

    <?php while (have_posts()) : the_post(); ?>
    <? if ((is_category()) && in_category($wp_query->get_queried_object_id())) { ?>

    <?php endwhile; ?>
     <?php } ?>
     
    Let us know if that works for you.

  5. KentonWebDesign
    Member
    Posted 4 months ago #

    Oops...

    <?php while (have_posts()) : the_post(); ?>
    <? if ((is_category()) & in_category($wp_query->get_queried_object_id())) { ?>

    <?php } ?>
    <?php endwhile; ?>
     

  6. Pankaj Pandey
    Member
    Posted 4 months ago #

    I think those questions are important when using WP as CMS.

    You need to work on your theme category.php to achieve desire result. its required knowledge of php loop and understanding of WordPress Framework. This is a core framework and you need to code your theme in such way that you can modify as per your need.

    KentonWebDesign is given you a example how to do that.

Reply

You must log in to post.

About this Topic