Site logo

Archived topic

Wrap archive results in template

7 replies · Started by William on June 10, 2022

Viewing posts 1–8 of 8

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

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.

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.

Generate before main content looks like this:

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

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

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

Glad to be of help!

This archived topic is closed to new replies.