in_the_loop()判断是否在主循环内部

目录

描述

Whether the caller is in The Loop (i.e. whether the loop is currently active).

in_the_loop() 描述

用法

<?php in_the_loop(); ?>

in_the_loop() 用法

参数

none.

in_the_loop() 参数

示例

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.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

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;
}

in_the_loop() 示例