Archived topic
Wrap archive results in template
7 replies · Started by William on June 10, 2022
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.
Hum, when I test on my end, it seems working:
https://www.screencast.com/t/eNs2E2tsevo
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:
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!