[Resolved] Wrap archive results in template

Home Forums Support [Resolved] Wrap archive results in template

Home Forums Support Wrap archive results in template

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2249492
    William

    Hi there,

    I am using FacetWP and want to install a filter option on archive pages. However, after talking to the developer, they have said the following:

    We need a way to add a

    directly around that list of articles / results. Do you have any idea how to pull that off? I have no idea how those article elements are currently being generated.

    Do you have any idea if this is possible or why FacetWP does not work with GeneratePress?

    Kind regards,

    Will

    #2249543
    Ying
    Staff
    Customer Support

    Hi Will,

    You can try using 2 hook elements, one uses generate_before_main_content, the other one uses generate_after_main_contenthook, priority set to 1.

    #2253515
    William

    Hi Ying, setting the generate_after_main_content and priority to 1 displays things after the content. I want it to be before the content. But, it does not load as intended due to the above screenshot.

    #2253560
    Ying
    Staff
    Customer Support

    Hum, when I test on my end, it seems working:
    https://www.screencast.com/t/eNs2E2tsevo

    #2255101
    William

    Generate before main content looks like this:

    And generate after main content with priority set to 1 looks like this?:

    #2255170
    David
    Staff
    Customer Support

    Hi there,

    it requires two hooks to wrap the articles.
    Instead of the method Ying provided try the following PHP Snippet:

    add_action('generate_before_loop', function(){
        if ( is_archive() ) {
            ?><div class="facetwp-template"><?php
        }
    });
    
    add_action('generate_after_loop', function(){
        if ( is_archive() ) {
            ?></div><?php
        }
    });

    For reference you can sse where those hooks are here:

    https://github.com/tomusborne/generatepress/blob/8bff7e067bb4df92ce1711fddb843585d4d18e71/archive.php#L41-L56

    And note – it will break the GP Columns. See this reply to correct that:

    https://generatepress.com/forums/topic/facet-wp-with-blog-archive/#post-2118241

    #2256169
    William

    Ah David that is amazing, thank you!!!!!!!

    #2258630
    David
    Staff
    Customer Support

    Glad to be of help!

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