![](/img/trans.png)
[英]How to show a content only in front page in WordPress using PHP logic?
[英]how to show page content area in the front site in wordpress
我是wordpress的新手,正在尝试创建一个网站。 单击相应的菜单项时,我需要显示页面的内容。 我的page.php包含
<?php while ( have_posts() ) : the_post();
$page_data= $post->ID;
if($page_data=='116') //Home page
{
?>
<center><b><h2>WELCOME TO THE CLINIC!!</h2></b></center>
<?php
}
else{ //for other pages
?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php
the_content();
}
endwhile; ?>
但我的内容没有显示。 标题显示正确。 代码中的错误是什么? 请帮我。
尝试这个 -
global $post; // if outside the loop
if ( is_home() || is_front_page() ) {
//your code here
} else {
// This is not the home page
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.