mtpultz
Member
Posted 5 months ago #
I tried to do this but " my custom text" appears after the more link
function wp_new_content($content) {
return $content." my custom text";
}
add_filter('the_content', 'wp_new_content');
I thought I could do it the same as the excerpt function below using get_the_content but instead replacing $text for $content and not checking for empty string but that doesn't work. So was trying to using the_content instead.
[code moderated - please follow the forum guidelines]
Mat Lipe
Member
Posted 5 months ago #
If you would like your text to display after the content you will want to use the add_action functions instead of add_filter. e.g.
function wp_new_content() {
echo "my custom text";
}
add_action('the_content', 'wp_new_content');
Give that a try.
Mat Lipe
Member
Posted 5 months ago #
I just realized the example I gave you will replace all the text. Try this instead.
function wp_new_content($content) {
echo $content."my custom text";
}
add_action('the_content', 'wp_new_content');
mtpultz
Member
Posted 5 months ago #
Thanks for the reply Mat, I tried the above but it still comes out after the more link I copied and pasted the page text below.
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent viverra lorem ut leo bibendum mattis egestas quam mollis. Donec at lacus sem. Sed fermentum cursus tellus sit amet bibendum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus ultrices ipsum sed quam viverra sit amet ornare metus ornare. Integer eu erat sit amet justo tristique ultrices. Morbi tristique, nisl ut dignissim congue, est velit blandit tellus, at rhoncus felis velit iaculis nisi.
Continue reading
my custom text"
Mat Lipe
Member
Posted 5 months ago #
I had to put my thinking cap on to remember how to do this, but I think I figured it out... See Below
Mat Lipe
Member
Posted 5 months ago #
`add_filter( 'excerpt_more', 'child_read_more_link' );
add_filter( 'get_the_content_more_link', 'child_read_more_link' );
add_filter( 'the_content_more_link', 'child_read_more_link' );
/**
* Custom Read More link.
*
*/
function child_read_more_link() {
return 'my custom Text <a href="' . get_permalink() . '" rel="nofollow">Continue Reading …</a>';
}
mtpultz
Member
Posted 5 months ago #
Hi Mat, thanks for the help that works great!!! I really appreciate the help :)
Cheers