Custom Category Page Template

Hi guys,

I’d like to add custom content to a specific category page using my child theme.

Can you point me in the right direction as to what file(s) I need to copy from the base theme over to my child theme?

Thanks!

Hi,

Thanks for writing in!

You can use hooks and filter to add your content.

eg. Add this in your child theme’s functions.php file

function add_custom_text() {   
    if(is_category(5)){
    ?>
    <div class="my-custom-text">
                  This is a sample text
      </div>
<?php    
}}
add_action( 'x_after_view_global__slider-below', 'add_custom_text', 10 );

The code I provided will add a text on the top of the category that has an id of 5(is_category(5))

For more information kindly refer to the links below



https://developer.wordpress.org/reference/functions/is_category/

Hope that helps

Perfect, thanks for this Paul!

You’re welcome! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.