十八、Wordpress独立页面的模板调用

admin2023-01-181380

blob.png

page.php    //独立页面模板,当独立页面模板不存在时,自动调用首页index.php模板显示

page.php

<? get_header(); ?>
<div class="c">
    <div id="page-box">
        <?
            the_post();    //独立页面内容和文章一样也用the_post()来获取,存入全局变量
        ?>
        <div class="post-item">
            <div class="post-title">
                <h2><a href="<? the_permalink(); ?>"><? the_title(); ?></a><h2>
            </div>
            <div class="post-meta">
                <? _e( 'author', 'huangcong' ); ?>:<? the_author(); ?><span>|</span>
                <? echo __( 'time', 'huangcong' ); ?>:<? the_time( 'Y-m-d' ); ?>
                <? edit_post_link( __( 'Edit','huangcong' ), ' <span>|</span> ', '' ); ?>
            </div>
            <div class="post-content"><? the_content(); ?></div>
        </div>
    </div>
</div>
<? get_footer(); ?>


网友评论