I just want to show only subcategories of specific parent category on parent category page.
I have 1 parent category videos
and 3 child categories art,funny,and technology
of that parent.
I didn’t assigned my parent videos
category to my child categories, but I made them child of that videos
parent cateogry.
and I don’t want to show parent categories on parent category page and neither want to show any category when go to any post related of child category page.
How to do this? any idea?
I am using this code. And I used this code into my category.php file.
<?php
if (is_category())
{
$cur_cat = get_query_var('cat');
if ($cur_cat)
{
$new_cats = wp_list_categories('echo=false&child_of=' . $cur_cat .'&depth=1&title_li=&&show_count=1&hide_empty=0');
}
}
?>
But this is not working desired as I want.
I also tried 1 more solution for that,I made another template called content-videos.php
and I call that template with
<?php if ( in_category('videos')):?>
<?php get_template_part( 'content', 'videos' ); ?>
<?php else:?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="block"><?php get_template_part( 'content', get_post_format() ); ?></div>
<?php endwhile; ?>
<?php endif;?>
in my category.php
template. and I put my 1st code into content-videos.php
.that solved my 1st problem, but my next problem was that when I go to in any subcategory page there is noting show except No categories
please suggest me any solution of this I am suffered too much to finding the right solution what I want.