Title: loop_start
Published: April 25, 2014
Last modified: February 24, 2026

---

# do_action_ref_array( ‘loop_start’, WP_Query $query )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#wp--skip-link--target)

Fires once the loop is started.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#parameters)󠁿

 `$query`[WP_Query](https://developer.wordpress.org/reference/classes/wp_query/)

The [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/) instance(
passed by reference).

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#source)󠁿

    ```php
    do_action_ref_array( 'loop_start', array( &$this ) );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-query.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-query.php#L3798)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-query.php#L3798-L3798)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Query::the_post()](https://developer.wordpress.org/reference/classes/wp_query/the_post/)`wp-includes/class-wp-query.php` |

Sets up the current post.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.0.0](https://developer.wordpress.org/reference/since/2.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/loop_start/?output_format=md#comment-content-6576)
 2.   [Lucas](https://profiles.wordpress.org/luquerias/)  [  3 years ago  ](https://developer.wordpress.org/reference/hooks/loop_start/#comment-6576)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Floop_start%2F%23comment-6576)
    Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Floop_start%2F%23comment-6576)
 4. A little code to append content **before the loop**:
 5.     ```php
        add_action( 'loop_start', 'wpdocs_loop_start_function' );
        function wpdocs_loop_start_function( $query ) {
            if ( condition ) {
                echo 'content';
            } else {
                echo 'content';
            }
        }
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Floop_start%2F%3Freplytocom%3D6576%23feedback-editor-6576)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Floop_start%2F)
before being able to contribute a note or feedback.