Custom content using in_category

How do I display a custom content using the in_category though using the parent category as a parameter and just selecting the subcategory on that category.

On my post I didn’t select the parent category so that it displays the permalink like /%category%/%postname%/ if I select the parent and the subcategory it will not show the subcategory on the permalinks which is required. if this is possible by just manipulating the permalink in the general settings it will also do the job.


Subcategory 1

Subcategory 2

Subcategory 3


<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if (in_category(‘category’)) { ?>
<?php the_content(); ?>
<?php } ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

Read more here:: Custom content using in_category

Leave a Reply

Your email address will not be published. Required fields are marked *