How to show category description

Support Forums for LiveMesh Themes & Plugins Forums Peak Theme Support How to show category description

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24178
    stoyanoff
    Member

    Hi there,
    We are using your theme to setup a custom site for the client. As always client comes each time with something new in mind and sometimes it is difficult for us to do it.

    We are not so skillful with theming for wordpress (that’s why we bought a ready made theme) and we need to show category description in category list. We create several categories and subcategories and client wants to show a description for some of the categories instead of list with published articles. We’ve checked theme files, but as it is custom made framework, we are not feeling sure that we can make it.

    Can you please provide help what to be included and in which files in the theme.
    We need to show category description if any instead of article list and if no description, then show article list.
    I hope that explain it well 🙂

    Thank you in advance.

    #24196
    Raghavendra
    Moderator

    I am not clear on where you want the category description to be shown. Can you pls provide a screenshot of a page which has the category information and where your client would like to see the category description? Need this info to provide the right code to make this happen. Thanks.

    #24197
    stoyanoff
    Member

    Well,
    If we create couple of categories and posts in them, when we browse a category, we see list of posts in this category. My client wants to use categories and subcategories and in some of the categories there will be no posts and instead of result “No posts were found with the criteria specified. Try searching again.”, client wants to show category description – check attached screenshot. Now description is shown in category header with category title.

    Hope this time is clear 🙂

    Thanks in advance again.

    #24230
    Raghavendra
    Moderator

    Pls replace the current content of the loop-error.php file to match your custom requirement –

    <?php
    /**
     * Loop Error Template
     *
     * Displays an error message when no posts are found.
     *
     * @package Peak
     * @subpackage Template
     */
    ?>
    <div id="post-0" <?php post_class(); ?>>
    
        <div class="entry-content clearfix">
    
            <?php if (is_category()) : ?>
    
                <div class="loop-meta">
                    
                    <div class="loop-description">
                        <?php echo category_description(); ?>
                    </div>
                    <!-- .loop-description -->
    
                </div><!-- .loop-meta -->
    
            <?php else: ?>
    
                <p><?php esc_html_e('No posts were found with the criteria specified. Try searching again.', 'peak'); ?></p>
    
                <?php get_search_form(); // Loads the searchform.php template. ?>
    
            <?php endif; ?>
    
        </div><!-- .entry-content -->
    
    </div><!-- .hentry .error -->

    You will need to remove the category description from the loop-meta.php file if you do not need it there at line number 39.

    #24231
    Raghavendra
    Moderator

    BTW, you can make these changes in the child theme without disturbing the parent theme by having files with the same name in child theme.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Peak Theme Support’ is closed to new topics and replies.