• Resolved justzamir

    (@justzamir)


    Hi there,

    I want to display category description on category archive below the title, How can i do this? I am using a child theme.

    // Function to display category description on category archive page
    function display_category_description() {
    if (is_category()) { // Check if it's a category archive page
    $category = get_queried_object(); // Get the current category object
    $category_description = category_description($category->term_id); // Get the category description

    if ($category_description) {
    echo '<div class="category-description">';
    echo '<h2>About ' . esc_html($category->name) . '</h2>';
    echo wp_kses_post($category_description); // Display the description safely
    echo '</div>';
    }
    }
    }

    // Hook to display category description before the category posts
    add_action('loop_start', 'display_category_description');

    Placed this in my function.php file but it displays the description above the header, I tried some tweaking but result is same.

    How can i do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • architalevelup

    (@architabasandrai20)

    Hi @justzamir

    Kadence provides the built-in function to display descriptions under titles for Archive pages, you can follow these steps:

    • Add category description in the backend.
    • Goto Customizer> Posts/Pages Layout > Archive Layout.
    • Scroll down to the Title elements
    • Uncheck the eye icon before a description. Check the screen recording: https://share.zight.com/rRuAW8LL

    I hope this helps. Please let us know if we can assist you further.
    ?
    Best Regards,
    Archita

    Thread Starter justzamir

    (@justzamir)

    That’s great. Since I’ve a bit long category descriptions, how can I truncate them to specific characters with option to click to read all. Also description text is aligned to center, how can I adjust CSS to make it align justified or align left.

    Hi there!

    While there’s no built-in way to add a “Show more” block for the category archives, you can look for plugins that could help you do that.

    Otherwise, custom coding is required and it’s outside of our support scope. For code reference, you can check out posts like this one.

    You can use the “text-align: left;” CSS property to control text alignments inside an element. The full CSS code will depend on your HTML output and the element CSS or IDs.

    Let me know if I can help you further.

    architalevelup

    (@architabasandrai20)

    Hi @justzamir

    Just checking in on this topic. Do you still need assistance here?

    If you’re all set, kindly set the topic as resolved. Otherwise, let us know if we can assist you further.

    Thread Starter justzamir

    (@justzamir)

    Yes, its resolved now. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.