Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在wordpress中获取页面内容?_Php_Wordpress - Fatal编程技术网

Php 如何在wordpress中获取页面内容?

Php 如何在wordpress中获取页面内容?,php,wordpress,Php,Wordpress,我正在创建一个名为“关于我们”的页面,并将永久链接设置为: 我还查询了页面内容,但得到的是空白(它没有显示上次修改页面的日期,也没有显示作者、内容段落) 代码如下: <?php $args = array( 'posts_per_page' => -1, 'post_type' => 'page', 'slug' => 'about-us' ); $the_query = new WP_Query( $args ); ?>

我正在创建一个名为“关于我们”的页面,并将永久链接设置为:

我还查询了页面内容,但得到的是空白(它没有显示上次修改页面的日期,也没有显示作者、内容段落) 代码如下:

<?php 
$args = array(
    'posts_per_page'   => -1,
    'post_type'        => 'page',
    'slug' => 'about-us'
);
$the_query = new WP_Query( $args );

?>
<?php get_header(  ); ?>
<?php
while ( $the_query->have_posts() ): $the_query->the_post();?>
<!--Main body-->
<div id="content">
      <div class="container">
          <div class="row">
            <div class="content-inner">
                            <!-- Left sidebar -->
             <div id="component" class="col-sm-12">
             <main role="main">

              <div id="system-message-container">
              </div>

<article class="page-item page-item__blog page-item__" itemscope="">
    <div class="item_info">
    <dl class="item_info_dl">
        <dt class="article-info-term">
        </dt>
            //Get the date last modified of the page
            <dd>
                <time datetime="2018-02-26 10:14" class="item_published">
                    <?php get_the_modified_date(  ); ?>     
                </time>
            </dd>
            <dd>
            //Get the author of the page
            <address class="item_createdby">
            <?php get_the_author(  ); ?>            
            </address>
        </dd>
    </dl>
</div>

//Get the paragraph in the page here
<div class="item_fulltext">
    <p>
        <?php echo $content?>
    </p>    
</div>
<!--End loop-->
<?php endwhile; ?>
<!--End of main body-->
<?php get_footer(  ); ?>

//获取页面上次修改的日期
//获取页面的作者
//在这里获取页面中的段落


page.php中编写代码,代替$content函数内容()将完成您的工作

<?php 
      get_header(); 
      $page_id=get_the_ID();
      $the_query = new WP_Query( array( 'p' => $page_id ) );

      while ( $the_query->have_posts() ): $the_query->the_post();
?>
       <div id="content">
      <div class="container">
          <div class="row">
            <div class="content-inner">
                            <!-- Left sidebar -->
             <div id="component" class="col-sm-12">
             <main role="main">

              <div id="system-message-container">
              </div>

<article class="page-item page-item__blog page-item__" itemscope="">
    <div class="item_info">
    <dl class="item_info_dl">
        <dt class="article-info-term">
        </dt>
            //Get the date last modified of the page
            <dd>
                <time datetime="2018-02-26 10:14" class="item_published">
                    <?php get_the_modified_date(); ?>     
                </time>
            </dd>
            <dd>
            //Get the author of the page
            <address class="item_createdby">
            <?php get_the_author(); ?>            
            </address>
        </dd>
    </dl>
</div>

//Get the paragraph in the page here
<div class="item_fulltext">
    <p>
        <?php the_content(); ?>
    </p>    
</div>
<?php 
      endwhile;
?>

//获取页面上次修改的日期
//获取页面的作者
//在这里获取页面中的段落


它是否显示任何html标记(即使没有内容)?或者html源是完全空的?它显示html标记,但标记中加载的内容是空的