最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

PHP Code in excerpt?

programmeradmin2浏览0评论

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 .

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论