0

I'm sitting here trying to figure out how to change the Read More text. I'm currently creating a Child Theme of Oxygen and as far as I can tell, they don't have a function to easily change it.

I want to change the text without copying over the entire index.php file though this is line 70:

<a class="read-more" href="<?php the_permalink(); ?>"><?php _e( 'Read Article', 'oxygen' ); ?> &rarr;</a>

I've tried different methods of changing it and even created a question on SO but have had no luck.

Is it possible, with this theme, to change the Read More text without copying over the entire index.php file and if so, how?

1

As this line of code is hardcoded in the index.php file rather than called via a function you only really have two options:

  • Write your own function to call this code (with your chosen read more text), then replace the relevant section in the child theme's index.php file with a call to this function. The function would go in your child theme's functions.php file.
  • Create a copy of the index.php file in your child theme, then change the hardcoded read more text to what you want it to be.

Obviously neither of these solutions solve the original problem (not wanting to copy over the index.php file).

It's also worth taking note of the comment at the top of the index.php file:

This is the default template. It is used when a more specific template can't be found to display posts. It is unlikely that this template will ever be used, but there may be rare cases.

Therefore for this change to take effect on all relevant pages you'll also want to edit page-template-front.php, archives.php, page-template-archives.php and search.php (I think that's all of them).

A more hacky approach would be to write a 'find and replace'-style function that looks for the current read more text and replaces it with something else, then call this function from your child theme's footer.php file.

In short, I don't think there's a way to switch out this text without copying at least one include or page template into your child theme.

0

From the Codex:

add_filter( 'the_content_more_link', 'modify_read_more_link' );
function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">Your Read More Link Text</a>';
}

Add this to the child theme's functions.php.

  • As you may not have seen in the SO page, that was the suggested answer there and it didn't work. – Spedwards Sep 18 '14 at 12:28
  • Oops, missed that. Re-reading the question again I see no other possibility that copying the files from the parent theme and making the changes. You could contact the developer of the parent theme and ask for a hook function to be used so that can be replaced in a child theme. – Kees de Bruin Sep 18 '14 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.