如何更改 WordPress 文章网格中的阅读更多文本
How to change the read more text in WordPress articles grid
那天我需要更改 post 网格的阅读更多文本,所以我使用了这段代码并且它工作正常。
function excerpt_read_more_link($output) {
global $post;
return $output . '<a class="more-link" href="'. get_permalink($post->ID) . '">voir plus</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');
现在我添加了一个名为 bouton_personnalise
的自定义 post 类型,我需要检查文章字段的作者是否为 bouton_personnalise,因此阅读更多文本应该是自定义 post 由作者输入,如果不显示阅读更多文本,所以我添加了这段代码,但它不起作用
function excerpt_read_more_link($output) {
global $post;
$text = 'voir plus';
if ( isset('bouton_personnalise'))
$text = 'bouton_personnalise';
return $output . '<a class="more-link" href="'. get_permalink($post->ID) . '">'. $text .'</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');
这是我的解决方案,以防有人遇到同样的问题
function excerpt_read_more_link($output) {
global $post;
$li = get_field('bouton_personnalise');
$text = 'Lire plus';
if ( isset( $li) )
$text = $li;
return $output . '<a class="vc_general vc_btn3 vc_btn3-size-md vc_btn3-shape-rounded vc_btn3-style-flat vc_btn3-color-juicy-maryam" href="'. get_permalink($post->ID) . '">'. $text .'</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');
那天我需要更改 post 网格的阅读更多文本,所以我使用了这段代码并且它工作正常。
function excerpt_read_more_link($output) {
global $post;
return $output . '<a class="more-link" href="'. get_permalink($post->ID) . '">voir plus</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');
现在我添加了一个名为 bouton_personnalise
的自定义 post 类型,我需要检查文章字段的作者是否为 bouton_personnalise,因此阅读更多文本应该是自定义 post 由作者输入,如果不显示阅读更多文本,所以我添加了这段代码,但它不起作用
function excerpt_read_more_link($output) {
global $post;
$text = 'voir plus';
if ( isset('bouton_personnalise'))
$text = 'bouton_personnalise';
return $output . '<a class="more-link" href="'. get_permalink($post->ID) . '">'. $text .'</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');
这是我的解决方案,以防有人遇到同样的问题
function excerpt_read_more_link($output) {
global $post;
$li = get_field('bouton_personnalise');
$text = 'Lire plus';
if ( isset( $li) )
$text = $li;
return $output . '<a class="vc_general vc_btn3 vc_btn3-size-md vc_btn3-shape-rounded vc_btn3-style-flat vc_btn3-color-juicy-maryam" href="'. get_permalink($post->ID) . '">'. $text .'</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');