我有以下代码片段:
<?php>$more = \'.....\';?>
<p class="extra"><?php the_excerpt(); ?></p>
我想做的是将$more的值附加到\\u execrpt()函数中,但不确定如何做。我尝试过:
<p class="extra"><?php the_excerpt() . $more; ?></p>
但是不行。任何帮助都将不胜感激。
谢谢
sp。
我有以下代码片段:
<?php>$more = \'.....\';?>
<p class="extra"><?php the_excerpt(); ?></p>
我想做的是将$more的值附加到\\u execrpt()函数中,但不确定如何做。我尝试过:
<p class="extra"><?php the_excerpt() . $more; ?></p>
但是不行。任何帮助都将不胜感激。
谢谢
sp。
function custom_excerpt_more( $more ) {
return \'...\'; // <-- your end string
}
add_filter( \'excerpt_more\', \'custom_excerpt_more\' );
http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_more
<p class="extra"><?php the_excerpt() . $more; ?></p>
将其更改为:<p class="extra"><?php the_excerpt(); echo $more; ?></p>
只需回显$more
节选后:
<p class="extra"><?php the_excerpt(); echo $more; ?></p>
或者更好的解决方案是使用过滤器并保持模板不变,例如,您的模板只使用the_excerpt()
<p class="extra"><?php the_excerpt(); ?></p>
<?php
//and this goes in your theme\'s functions.php file
add_filter(\'the_excerpt\',\'my_excerpt_more\');
function my_excerpt_more($excerpt){
return $excerpt. \'.....\';
}
首先,我知道单独使用插件比在函数中集成插件更好。php,但这是用于将部署到多个站点的主题框架,并且将其打包为主题的一部分会更容易。我在使用位于此处的插件中的以下代码时遇到问题。我的PHP知识有限,我曾尝试直接复制和粘贴代码,但不起作用,但作为插件使用时效果很好。class Filosofo_Custom_Image_Sizes { public function __construct() { add_filter(\'image_downsize\', arra