最新公告
  • 欢迎您光临站盟网(原知事网),一个优质的网站源码基地、精品网站模板和插件。欢迎加入永久SVIP
  • WordPress函数get_the_ID()用法 显示当前文章ID

    正文概述 知事网   2020-09-11 10:09   514

    描述:

    显示当前文章ID

    参数:

    此函数没有参数

    用法:

    <?php get_the_ID(); ?>

    示例:

    <?php
    $id = get_the_ID();
    $dropdown = "<select name='dropdown-".$id."' >";
    $dropdown .= "<option id='option1-". $id ."'>Option 1</option>";
    $dropdown .= "</select>";
    ?>

    源文件:

    /**
     * Retrieve the ID of the current item in the WordPress Loop.
     *
     * @since 2.1.0
     *
     * @return int|false The ID of the current item in the WordPress Loop. False if $post is not set.
     */
    function get_the_ID() {
    	$post = get_post();
    	return ! empty( $post ) ? $post->ID : false;
    }

    站盟网 » WordPress函数get_the_ID()用法 显示当前文章ID

    发表评论

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

    如需帝国cms功能定制以及二次开发请联系我们

    联系作者
    请选择支付方式
    ×
    支付宝支付
    微信支付
    余额支付
    ×
    微信扫码支付 0 元