[Resolved] Is it possible to show on element only on the first page or an archive?

Home Forums Support [Resolved] Is it possible to show on element only on the first page or an archive?

Home Forums Support Is it possible to show on element only on the first page or an archive?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1454388
    Samuel

    The subject says it all–is there a way I can show an element on a blog page but only on the first page?

    #1454390
    Leo
    Staff
    Customer Support

    Hi there,

    See the second example here:
    https://docs.generatepress.com/article/generate_header_element_display/#examples

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

    Let me know if this helps πŸ™‚

    #1454430
    Samuel

    Unless I’m missing something this doesn’t cover my use case. My use case is:

    On the blog page insert a block element using the before content hook.

    However I want to only show this element on the first page of the blog archive.

    #1454435
    Leo
    Staff
    Customer Support

    It should work just with a different filter:

    add_filter( 'generate_block_element_display', function( $display ) {
        if ( is_paged() ) {
           $display = false;
        }
    
        return $display;
    } );

    Let me know πŸ™‚

    #1454457
    Samuel

    Got it–what is available to the filter to target that one element? Is the id, etc passed to the filter?

    #1454458
    Leo
    Staff
    Customer Support
    #1455119
    Samuel

    Got it thanks

    #1455532
    Leo
    Staff
    Customer Support

    No problem πŸ™‚

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.