【问题标题】:how to show page content area in the front site in wordpress如何在wordpress的前端显示页面内容区域
【发布时间】:2013-10-30 07:42:07
【问题描述】:

我是 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; ?>

但我的内容没有显示。标题显示正确。代码中的错误是什么?请帮帮我。

【问题讨论】:

  • 您在管理端内容区添加了内容?

标签: php wordpress


【解决方案1】:

试试这个 -

global $post;     // if outside the loop

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

    //your code here

} else {

    // This is not the home page
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-24
    • 2020-03-20
    • 1970-01-01
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多