最新公告
  • 欢迎您光临知事网软件APP资源下载站,一个优质的手机App应用商店和网站源码基地。欢迎加入永久SVIP
  • WordPress函数the_ID() 自定义页面用the_ID()调用内容

    正文概述 知事网   2020-09-09 10:09:24   418

    描述:今天想自己新建一个页面模板,用来做个简单的自定义页面,当调用页面内容时需要用到the_ID()来获取页面ID,这样才能方便调用内容到自定义页面。

    目的:调用显示当前自定义页面ID。

    用法:

    <?php the_ID(); ?>

    示例:

    <p>Post Number: <?php the_ID(); ?></p>

    自定义模板代码:

    <?php 
    /**
     * Template name: 服务项目
     * Description:   A tags page
     */
    get_header();
    ?>
    <div class="container">
        <div class="row-fw">
                <?php
                    $page_id = get_the_ID(); //get_the_ID()调用页面ID
                    echo get_post($page_id)->post_content; //此段为输出获取的页面内容,无需修改
                ?>
        </div>
    </div>
    <?php get_footer(); ?>

    在页面内填入内容即可调用在前台显示,非常简单方便。


    知事网 » WordPress函数the_ID() 自定义页面用the_ID()调用内容

    发表评论

    还没有评论,快来抢沙发吧!

    [!--temp.right--]
    请选择支付方式
    ×
    余额支付
    ×
    微信扫码支付 0 元