嘿,有没有可能我可以把一段代码放在某个地方,它会出现在更多的标记分隔符之后,但在帖子中?
我的意思是,如果我在第一段后面加上更多的分隔符,那么在后面的帖子区域会显示我要加的代码。。可能是一些带有twitter和rss链接的html。
感谢您的帮助:)谢谢
嘿,有没有可能我可以把一段代码放在某个地方,它会出现在更多的标记分隔符之后,但在帖子中?
我的意思是,如果我在第一段后面加上更多的分隔符,那么在后面的帖子区域会显示我要加的代码。。可能是一些带有twitter和rss链接的html。
感谢您的帮助:)谢谢
这将在more
贴子页面上的标记区域:
add_filter(\'the_content\', \'adds_block\');
function adds_block($content) {
if (is_single()) {
// return $content;
global $post;
$thePostID = $post->ID;
$test = \'<span id="more-\' .$thePostID.\'"></span>\';
return str_replace($test, ads(), $content);
}
}
function ads(){
return \'Your Custom Code,,\';
}
您可以使用\\u tags挂钩将代码添加到标记输出中,如下所示:
function add_my_code_after_tags($tags){
$my_code =$tags . "your output here";
return $my_code;
}
add_filter(\'the_tags\',\'add_my_code_after_tags\');
过滤器打开the_content_more_link
可能适合您,过滤器应该让您完全控制more链接,这样您就可以添加、删除它,或者预先/暂停一些额外的内容。
下面是一个示例,取消注释适当的行以进行前置或追加(即在链接之前或之后放置额外内容)。
add_filter( \'the_content_more_link\', \'custom_more_link\', 1000 );
function custom_more_link( $more_link ) {
$extra_more = \'<br />My more link extra content\';
// Uncomment line below to prepend content
//return $extra_more . $more_link;
// Uncomment line below to append content
//return $more_link . $extra_more;
}
NOTE: 额外的内容必须存储在返回的变量中。进一步阅读/示例
http://codex.wordpress.org/Customizing_the_Read_More
http://justintadlock.com/archives/2009/07/01/how-to-filter-a-wordpress-themes-more-link-text
希望有帮助:)
目前,我使用posts_where 过滤器: function filter_where( $where = \'\' ) { $where .= \" AND post_date >= \'2000-01-01\' AND post_date <= 2004-12-31\' \"; return where; } add_filter(\'posts_where\', \'filter_where\'); query_posts($que