Php 有条件地替换后摘录;阅读更多“;链接
我已经编写了一个函数,用我自己的替换WordPress默认的文章摘要“阅读更多”链接,这是可行的,但现在我试图用特定页面上稍微不同的HTML属性替换它,但我遇到了语法错误 功能:Php 有条件地替换后摘录;阅读更多“;链接,php,wordpress,Php,Wordpress,我已经编写了一个函数,用我自己的替换WordPress默认的文章摘要“阅读更多”链接,这是可行的,但现在我试图用特定页面上稍微不同的HTML属性替换它,但我遇到了语法错误 功能: function new_excerpt_more($more) { global $post; if (is_page( '39' )) { return ' […]<p><a class="moretag btn btn-primary btn-xl
function new_excerpt_more($more) {
global $post;
if (is_page( '39' )) {
return ' […]<p><a class="moretag btn btn-primary btn-xl wow bounceIn" href="'. get_permalink($post->ID) . '">Continue reading <span aria-hidden="true">→</span></a></p>';
}
} else {
return ' […]<p><a class="moretag btn btn-primary btn-md" href="'. get_permalink($post->ID) . '">Continue reading <span aria-hidden="true">→</span></a></p>';
}
}
add_filter('excerpt_more', 'new_excerpt_more');
任何帮助都将不胜感激。提前谢谢 你有一个过多的结束曲括号
function new_excerpt_more($more) {
global $post;
if (is_page( '39' )) {
return ' […]<p><a class="moretag btn btn-primary btn-xl wow bounceIn" href="'. get_permalink($post->ID) . '">Continue reading <span aria-hidden="true">→</span></a></p>';
}
else {
return ' […]<p><a class="moretag btn btn-primary btn-md" href="'. get_permalink($post->ID) . '">Continue reading <span aria-hidden="true">→</span></a></p>';
}
}
add_filter('excerpt_more', 'new_excerpt_more');
函数新建\u摘录\u更多($更多){
全球$员额;
如果(是第页('39')){
返回“[…;]”;
}
否则{
返回“[…;]”;
}
}
添加过滤器(“摘录更多”、“新摘录更多”);
您的右括号过多
function new_excerpt_more($more) {
global $post;
if (is_page( '39' )) {
return ' […]<p><a class="moretag btn btn-primary btn-xl wow bounceIn" href="'. get_permalink($post->ID) . '">Continue reading <span aria-hidden="true">→</span></a></p>';
}
else {
return ' […]<p><a class="moretag btn btn-primary btn-md" href="'. get_permalink($post->ID) . '">Continue reading <span aria-hidden="true">→</span></a></p>';
}
}
add_filter('excerpt_more', 'new_excerpt_more');
函数新建\u摘录\u更多($更多){
全球$员额;
如果(是第页('39')){
返回“[…;]”;
}
否则{
返回“[…;]”;
}
}
添加过滤器(“摘录更多”、“新摘录更多”);
现在我看到了。深夜编写代码的缺点之一是睡眠不足。谢谢现在我明白了。深夜编写代码的缺点之一是睡眠不足。谢谢第一次返回后有一个额外的}第一次返回后有一个额外的}