WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/in the loop

Contents

Description

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

Usage

<?php in_the_loop(); ?>

Parameters

none.

Examples

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.

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

Return Value

(boolean) 
True if caller is within loop, false if loop hasn't started or has ended.

Changelog

Since: 2.0.0

Source File

in_the_loop() is located in wp-includes/query.php.

See also index of Function Reference and index of Template Tags.