WordPress.org

Ready to get started?Download WordPress

Forums

A problem when posting in sub Cat (2 posts)

  1. Pickells
    Member
    Posted 1 year ago #

    hello
    i have this problem

    when i post in a sub category the full post shows also in the parent category !!

    i want to show only partial of the post in the parent and a link to the full post in the sub .

    any help will be appreciated !!

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    category archives are also showing the posts of subcategories by default;

    you would need to edit category.php of your theme (if your theme does not have one, create anew from a copy of archive.php or index.php);

    in the loop, change for example:

    <?php the_content(); ?>

    to:

    <?php if( in_category( get_query_var('cat') ) {
      the_content();
    } else {
      the_excerpt();
    } ?>

    (untested)

    the post title would generally already link to the full post.
    if you want to link to the sub category instead, you also need to change the coding ot the_title() line...

Topic Closed

This topic has been closed to new replies.

About this Topic