0

I'm trying to add the 'Hello world' from this code:

add_filter( 'the_content', function( $content ) {
  return $content . ' <br /> Hello World ';
}, 0);

Before the "read more" link that that sends to single page. As you can see this code ads the hello word after the "read more", and I would like it just before, but after the rest of the content.

Is there a hook for this? If possible I prefer to keep this in functions.php rather than in template.

1 Answer 1

0

Yes, you could use the filter the_content_more_link.

Here is the example

add_filter( 'the_content_more_link', 'q363666_tweak_more_link', 10, 2 );
function q363666_tweak_more_link( $more_link, $more_link_text ) {
  // WordPress prepared the $more_link
  // you can intercept here and return whatever you need
  return 'Hello World ' . $more_link;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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