admin管理员组

文章数量:1431272

Is there a way I can add <a href="<?php the_permalink() ?>" rel="bookmark" title="Read more at: <?php the_title(); ?>"><?php the_title(); ?></a> in the excerpt manually?

Is there a way I can add <a href="<?php the_permalink() ?>" rel="bookmark" title="Read more at: <?php the_title(); ?>"><?php the_title(); ?></a> in the excerpt manually?

Share Improve this question asked Apr 19, 2019 at 22:23 user159405user159405
Add a comment  | 

1 Answer 1

Reset to default 1

Any PHP code in the post content will get stripped out and not executed. This is a safety issue; you don't want to allow authors to put in executable code.

To display code in a post, BTW, you would surround it with the <code> tag,

If you want to modify what the excerpt displays, you can use the get_the_excerpt filter, similar to this:

function filter_function_name( $excerpt ) {
  $excerpt .= "Thanks!";
}
add_filter( 'get_the_excerpt', 'filter_function_name' );

Which will add the word "Thanks!" after the excerpt. More examples in the codex here: https://codex.wordpress/Plugin_API/Filter_Reference/get_the_excerpt .

本文标签: PHP Code in excerpt