WordPress函数in_the_loop()

描述:

判断是否在主循环内部

用法:

<?php in_the_loop(); ?>

参数:

None

示例:

add_filter( 'the_title', 'modify_single_post_entry_titles' );

function modify_single_post_entry_titles( $title ) {

	if ( is_singular( 'post' ) && in_the_loop() ) {

		/* Modify $title */

	}

	return $title;
}

源文件:

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