in_the_loop() - WordPress 函数参考中文文档

返回介绍

in_the_loop()

发布于 2017-09-11 字数1619 浏览 867 评论 0

in_the_loop()

Whether the caller is in the Loop.


描述


返回值

(bool) True if caller is within loop, false if loop hasn’t started or ended.


源代码

File: wp-includes/query.php

function in_the_loop() {
	global $wp_query;
	return $wp_query->in_the_loop;
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Used By

  • wp-includes/post-thumbnail-template.php:
    get_the_post_thumbnail()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Modify Single Post Entry Titles

    For use in your functions file, this code example enables you to modify the default output of your entry titles.

    
    function wpdocs_modify_single_post_entry_titles( $title ) {
    
    	if ( is_singular( 'post' ) && in_the_loop() ) {
    		/* Modify $title */
    	}
    
    	return $title;
    }
    add_filter( 'the_title', 'wpdocs_modify_single_post_entry_titles' );
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!