Use php code with if else statement and design single.php for specific parent category’s post. So use given php code on your WordPress theme.
How To Do
- Open functions.php file then paste given code first.
function post_design_parent_category_thekroyaard($parent_category_name) { $categories = get_the_category(); foreach ($categories as $category) { if ($category->category_parent === get_cat_ID($parent_category_name)) { return true; } } return false; }
- Now SAVE this code and open single.php and paste second code there.
<?php
if ( post_design_parent_category_thekroyaard('categiry_name')) {
?>
<div class="entry-content-category-hindi">
<?php the_content(); ?>
</div>
<?php
} else {?>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php
}
?>
- Then SAVE single.php file. and design different layout for category’s post.
if you want to another type help so contact-us otherwise thanks for visiting.
For Multiple Categories
Use both code on your website theme and follow same procedure.
Code for functions.php
function post_design_parent_categories_thekroyaard($parent_category_names) { $categories = get_the_category(); foreach ($categories as $category) { if (in_array($category->category_parent, array_map('get_cat_ID', $parent_category_names))) { return true; } } return false; }
Code for single.php
if ( post_design_parent_categories_thekroyaard(array('parent-category-1', 'parent-category-2'))) {
?>
<div class="entry-content-category-hindi">
<?php the_content(); ?>
</div>
<?php
} else {
?>
<div class="entry-content">
<?php
the_content();
?>
</div>
<?php
}
?>
You can use it on WordPress theme.