简体   繁体   English

如何在wordpress的前站点中显示页面内容区域

[英]how to show page content area in the front site in wordpress

i'm new to wordpress and i'm trying to create a website. 我是wordpress的新手,正在尝试创建一个网站。 i need display the content of the pages when corresponding menu items are clicked. 单击相应的菜单项时,我需要显示页面的内容。 my page.php contain 我的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; ?>

but my content is not displaying. 但我的内容没有显示。 title is showing properly. 标题显示正确。 what is the mistake in the code? 代码中的错误是什么? please help me. 请帮我。

Try this - 尝试这个 -

global $post;     // if outside the loop

if ( is_home() || is_front_page() ) {

    //your code here

} else {

    // This is not the home page
}

Reference link - http://codex.wordpress.org/Conditional_Tags 参考链接-http://codex.wordpress.org/Conditional_Tags

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用PHP逻辑仅在WordPress的首页显示内容? - How to show a content only in front page in WordPress using PHP logic? 如何在WordPress首页显示帖子缩略图 - How to show post thumbnail in wordpress front page 如何为注销和登录用户显示不同的 WordPress 首页? - How to show different WordPress front page for logged out and logged in users? Wordpress PHP如何使主题显示静态首页代码 - Wordpress PHP How to make theme show Static front page code 如何通过视觉作曲家在前端WordPress页面上显示图像? - How to show image on front end WordPress page by visual composer? 如何在Wordpress中显示另一页面的部分内容? - How to show partial content of a page on another in wordpress? WordPress一页网站(首页上的页面) - WordPress One page site (page on front-page) 在Wordpress的单独页面中显示内容 - Show content in separate page in wordpress 如何通过更改“首页”设置来强制主页重定向并禁用 Wordpress 站点上的主 header? - How do I force home redirects and disable main header on a Wordpress site, by just changing the “Front page” settings? 我有一个 wordpress 站点,其中设置了一个 cookie,用于确定要在首页上显示的图像/文本。 它总是在 mac 上工作,很少在 windows 上工作 - I have a wordpress site where a cookie is set determining what image/text to show on the front page. It works on mac always, on windows rarely
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM