如何在WordPress中获取functions.php文件中的函数?
我想从functions.php文件中获取此函数如何在WordPress中获取functions.php文件中的函数?,php,wordpress,function,Php,Wordpress,Function,我想从functions.php文件中获取此函数 function twentyseventeen_excerpt_more( $link ) { if ( is_admin() ) { return $link; } $link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
function twentyseventeen_excerpt_more( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue readingggg<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ), get_the_title( get_the_ID() ) )
);
return ' … ' . $link;
}
add_filter( 'excerpt_more', 'twentyseventeen_excerpt_more' );
function Twenty17\u摘录\u更多($link){
if(is_admin()){
返回$link;
}
$link=sprintf(“”,
esc_url(get_permalink(get_the_ID()),
/*翻译人员:%s:当前帖子的名称*/
sprintf('Continue readingggg“%s”,'twentyeven'),获取标题(获取ID())
);
返回“&hellip;”。$link;
}
添加过滤器(“摘录更多”、“二十一七摘录更多”);
例如,在我的shorcode文件中删除带有空字符串的“Continue readinggg”文本(或者干脆删除它)。我怎么做?
我必须在本声明中使用:
if($content=='true'){
the_content();
}
if( $excerpt=='true' ) {
if( $readmore=='true' ) {
echo get_the_excerpt()."<a href='".get_permalink($article_id)."'><button>Read More</button></a>";
} else {
the_content();
}
}
if($content==“true”){
_内容();
}
如果($摘录=='true'){
如果($readmore=='true'){
echo获取摘录();
}否则{
_内容();
}
}
如何做到这一点?您应该在短代码中调用相同的筛选器,但优先级更高:
your_shortcode_function() {
// Your code
add_filter( 'excerpt_more', 'my_excerpt_code', 20 );
}
function my_excerpt_code($link) {
return '';
}
Twenty177函数的默认优先级为10,如果您设置了更高的优先级,它将在之后执行,因此它应该删除链接
编辑:
好的,如果您只想删除包含_内容的摘录,可以使用以下方法:
the_content(null, false);
正如你在这里看到的:
它应该删除“查看更多”按钮。我已经编辑了我的问题。你能看一下吗?