WordPress 函数:add_links_page()

确定查询是否适用于现有附件页面。

原型

is_attachment( int|string|array|object $attachment = '' )

描述

有关此功能和类似主题功能的更多信息,请查看Theme Developer Handbook中的Conditional Tags文章。

参数

$attachment (int|string|array|object) (Optional) 附件ID,标题,slug或其中的数组。

返回值

(bool)  

源文件

路径:wp-includes/query.php

<?php
...
function is_attachment( $attachment = '' ) {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
        return false;
    }

    return $wp_query->is_attachment( $attachment );
}

...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/is_attachment/

1个回复

  1. It's actually a nice and helpful piece of info.
    I'm satisfied that you shared this useful information with us.
    Please stay us up to date like this. Thank you for sharing.

发表评论

电子邮件地址不会被公开。 必填项已用*标注