Support » Fixing WordPress » Changing Read More Text By Category

  • Hi,

    I want to change the ‘read more’ text for an individual category.

    I figured out how to change the ‘read more’ text across all t he posts, but is there any way to customize the ‘read more’ only for posts in a certain category?

    I am using the Theme ‘Bulk’.

    Thank you!

    • This topic was modified 2 months, 1 week ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @yamiwakatanakatta,

    I tried to look at the Bulk theme and noticed that there is no direct way (action/filter hook) to allow modification to the Read More text across the templates in the theme.

    The best way I see this could be achieved is by overriding the theme template(s) via a child theme. Bulk theme uses template-parts to render various sections of the frontend layout. You could just copy the contents of content.php (found in the root of Bulk theme directory), create a file with the same name in your child theme. Follow the other instructions here: https://developer.wordpress.org/themes/advanced-topics/child-themes/#how-to-create-a-child-theme to create the child theme in the right manner.

    You can then add if ( is_category( 'category_id' ) ) condition on line number 24 in content.php and modify the text for Read More button. See below for an example:

    <?php if ( is_category( 'category_id' ) ) : // use singular or array of category slug, name or IDs ?>
        <?php esc_html_e( 'Learn more', 'bulk' ); ?>
    <?php else : ?>
        <?php esc_html_e( 'Read more', 'bulk' ); ?>
    <?php endif; ?>

    Read more about is_category here: https://developer.wordpress.org/reference/functions/is_category/.

    Let me know if that helps you. Cheers!

    yamiwakatanakatta

    (@yamiwakatanakatta)

    Thank you so much for this!

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