如何解决如何在wordpress的博客列表页面上添加静态文本?
所以,我从oceanWP创建了一个子主题。
我决定添加我的functions.php .....
function echo_comment_id( $comment_id ) {
if ( is_home() ){
$content = 'hi there';
echo $content;
}
return $content;
}
add_action( 'the_content','echo_comment_id',10,1 );
我的“嗨,那里”打印了两次……回声的原因。 没有回声,什么都不会打印出来。
我以为它会被隐藏或立即消失?
解决方法
wpbf_main_content_open
不是本机Wordpress钩子,它似乎是Page Builder Framework中的钩子。您是否使用Page Builder Framework?
但是,您想要的可以通过本机函数完成。
动作挂钩loop_start
// place this in your functions.php
add_action( 'loop_start','add_static_text_on_blog_list_page' );
function add_static_text_on_blog_list_page( ) {
// Check if this is the Blog-Post-Page and main query.
if ( is_home() && is_main_query() ) {
echo '<h1>Hey everyone!</h1><p>This is a quick intro.</p>';
}
}
另一种方法是Custom Blog Posts Index Page Template。从page.php
(如果在父主题中存在,则为home.php
)进行复制,并在子主题中另存为home.php
。然后,您可以将静态文本添加到此模板中(在lopp启动之前)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。