简体   繁体   中英

Issue with adding function in functions.php [Wordpress]

I write function in functions.php like this

function out() {
  $s = 'End of the post, thanks for reading';
  return $s;
}

add_filter('the_content','out');

and I expect this to be fetched at the end of the post, after entry content. But all it does is that post entry ( what the_content outputs) is not shown, and I only get 'End of the post, thanks for reading'.

What am I doing wrong?

Try this:

function out($content) {
  return $content . ' End of the post, thanks for reading';
}
add_filter( 'the_content', 'out' );

Can you try this

function out($content) {
  $content .= '<br>End of the post, thanks for reading';
  return $content;
}

add_filter('the_content','out');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM