Register Register
asked 10 years ago

Hi Domanic ,
I Had check this post : http://www.designwall.com/question/post-page-style-same-like-category-style/
and find that there is an option to show up the catagory with its defined color in post ,

In Admin panel In widget option we have an option to Show the meta infomation of post and selected "show the catagory info " Its works fine .
Is there any option to get the color of its catagory .

2 Answers
DominicStaff
answered 10 years ago

Hi,
To resolve this issue, you can open the widgets file in the \wp-content\themes\dw-focus\inc\widgets folder.
Find the following code:

<?php 
                            if( isset( $instance['cat'] ) && $instance['cat'] ) {
                                $categories_list = get_the_category_list( __( ', ', 'dw_focus' ) );
                                    if ( $categories_list && dw_focus_categorized_blog() ) :
                                ?>
                                <span class="cat-links">
                                    <?php printf( '%1$s', $categories_list ); ?>
                                </span>
                                <?php
                                endif;
                            }
                        ?>

Then replace with the following code:

<span class="cat-links">
<?php $sep = '';
foreach((get_the_category()) as $cat) {
    echo $sep . '<a href="' . get_category_link($cat->term_id) . '"  class="cat-' . $cat->slug . '" title="View all posts in '. esc_attr($cat->name) . '">' . $cat->cat_name . '</a>';
$sep = ', ';
}
?>

Right now, you can use class cat- to change the Categories color.
Eg: your categories: Blog / Business / Entertainment.

Your Class:

.cat-blog {...}
.cat-business {....}
cat-entertainment {...}

Hope this helps !

Register Register
answered 10 years ago

Yes Domanic works awesome thanks save my day,

register
replied 10 years ago

Hi Domanic i am back with a small question ,
Is there any possibilities to shortout the category which is showing in frontend on widget display area , I have selected more than one category for some post in frontend it displayed all the category which is got selected . Is there a way to display only selected category using category id or something like that.

dominic Staff
replied 10 years ago

Unfortunately, our theme do not support to make as you want.

Powered by DW Question & Answer Pro