Site logo

Archived topic

Display Hook on 1st page of archive only?

3 replies · Started by nomadiceman on July 27, 2021

Viewing posts 1–4 of 4

Is it possible to display a element Hook on the 1st page of an archive only?

or even some how select what page of the archive it should be shown on? So Page 1 has element hook A, page 2 has element hook B etc. etc

Hi there,

Try this PHP snippet:

add_filter( 'generate_element_display', function( $display, $element_id ) {
    if ( 1111 === $element_id && is_paged() ) {
        $display = false;
    }

    return $display;
}, 10, 2 );

Change 1111 to the actual ID of the element.

Adding PHP: https://docs.generatepress.com/article/adding-php/

Let me know if this helps :)

Awesome. So what part do I add which archive page it should show on 1st, 2nd, 3rd etc?

This archived topic is closed to new replies.