包含另一页中的一页的Wordpress

时间:2018-09-25 09:08:12

标签: php wordpress

我有一个php页面,其中包含一些html内容,这些内容将出现在多个页面上。因此,我希望能够以与包含页眉和页脚相同的方式在其他页面上包含该页面。我以前做过,但是我不记得如何,您能帮忙吗?

1 个答案:

答案 0 :(得分:0)

您可以使用WP_Query并将post_type设置为page,将page_id设置为要输出的页面。然后循环浏览内容:

<?php
$args = array(
    'post_type' => 'page'
    'page_id' => '20'
);
$query = new WP_Query( $args );
?>
<?php if ( $query->have_posts() ) : ?>
    <?php while ( $query->have_posts() ) : $query->the_post(); ?>

    // Contents of the queried ppage results go here.

    <?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>

还有一个看起来像您想要的插件的insert page