Design System is here - Read the release post

Learn GeneratePress

Developers

Article hooks

These hooks fire around a single article’s content — the post, page, or archive entry.

Where the article hooks fire A wireframe of a single article (post, page or archive entry), with each hook labelled where it fires. The same hooks are listed in firing order in the text list below this diagram. Around the article generate_before_do_template_part generate_before_content Inside the article generate_after_entry_header generate_after_entry_content After the article generate_after_content generate_after_do_template_part

Hooks in firing order

  1. generate_before_do_template_part
  2. generate_before_content
  3. generate_after_entry_header
  4. generate_after_entry_content
  5. generate_after_content
  6. generate_after_do_template_part

Around the article

generate_before_do_template_part

GP Free

The generate_before_do_template_part hook appears at the start of generate_do_template_part() function.

Parameters: $template. Default: —.

add_action( 'generate_before_do_template_part', function( $template ) {
    ?>
    <div class="my-notice">Insert your content here.</div>
    <?php
} );

Related: generate_after_do_template_part Guide: Content

generate_before_content

GP Free

The generate_before_content hook appears inside the .inside-article element.

Parameters: none. Default: —.

add_action( 'generate_before_content', function() {
    ?>
    <div class="my-notice">Insert your content here.</div>
    <?php
} );

Related: generate_after_content Guide: Content

Back to top

Inside the article

generate_after_entry_header

GP Free

The generate_after_entry_header hook appears after the .entry-header element.

Parameters: none. Default: —.

add_action( 'generate_after_entry_header', function() {
    ?>
    <div class="my-notice">Insert your content here.</div>
    <?php
} );

Guide: Content

generate_after_entry_content

GP Free

The generate_after_entry_content hook appears after the .entry-content element.

Parameters: none. Default: —.

add_action( 'generate_after_entry_content', function() {
    ?>
    <div class="my-notice">Insert your content here.</div>
    <?php
} );

Guide: Content

Back to top

After the article

generate_after_content

GP Free

The generate_after_content hook appears before the closing .inside-article element.

Parameters: none. Default: —.

add_action( 'generate_after_content', function() {
    ?>
    <div class="my-notice">Insert your content here.</div>
    <?php
} );

Related: generate_before_content Guide: Content

generate_after_do_template_part

GP Free

The generate_after_do_template_part hook appears at the end of generate_do_template_part() function.

Parameters: $template. Default: —.

add_action( 'generate_after_do_template_part', function() {
    global $wp_query;

    if ( 3 === $wp_query->current_post ) {
        echo 'Look at me after the fourth post';
    }
} );

Related: generate_before_do_template_part Guide: Content

Back to top