Php 如何仅在主页上添加新闻摘要

Php 如何仅在主页上添加新闻摘要,php,wordpress,Php,Wordpress,我安装了一个新闻代码插件 然后我在sidebar.php中添加了必要的函数/代码 <!-- BEGIN: #secondary --> <div id="secondary" class="g1-sidebar widget-area" role="complementary"> <h3>Latest News</h3> <div id="news"> <?php if ( function_exists('insert_news

我安装了一个新闻代码插件

然后我在sidebar.php中添加了必要的函数/代码

<!-- BEGIN: #secondary -->
<div id="secondary" class="g1-sidebar widget-area" role="complementary">
<h3>Latest News</h3>
<div id="news">
<?php if ( function_exists('insert_newsticker') ) { insert_newsticker(); } ?>
</div>
.......
.........
</div>

最新消息
.......
.........
现在,所有页面的侧栏上都出现了新闻

但我希望它只添加在主页sideabr

有没有办法做到这一点,所以如果侧栏是主/主

然后只显示新闻代码

使用
is_front_page()
进行首页检查

if( is_front_page() && function_exists('insert_newsticker') ){
    insert_newsticker();
}
更多信息

根据评论更新:

//你的h3标签在这里
最新消息

使用“is_home”功能更多详细信息:

美元服务器[“请求URI]将包含当前地址的URI,因此如果您将其与主页(“/”)进行比较它将允许您查看是否插入该插件。如果您决定稍后在站点上添加插件,您还可以相当轻松地添加对其他页面的支持。

is_home()
实际检查博客索引页,这不是静态主页感谢工作正常,还有一件事,如果页面是主页,如何在侧边栏中动态添加一个标记page@PK10请检查更新的代码,并希望你喜欢这样。是的,正是你得到了它,但我得到的新闻标题“最新消息”“在每一页上,并且只希望它出现在主页上
<div id="secondary" class="g1-sidebar widget-area" role="complementary">
<?php if( is_front_page() ): ?>
// Your h3 tag here
<?php endif; ?>
<h3>Latest News</h3>
<div id="news">