Hi,
I have setup a filter for my custom post type. I have also a custom page, where the results should be seen. But when I filter, the URL change correctly somthing like example.com/my_page/?_sfm_filter=test
Settings:
Display results method: As an archive
Template Options: Use a custom template for results check
Enter the filename of the custom template: achrive-my_page.php
Set a slug: example.com/my_page/
I know why it’s not working. I found in the documentation: When using the archive method Search & Filter uses the pre_get_posts action to modify the The Loop with your search parameters (The Loop basically is the query that fetches all your posts)
I need to add pre_get_posts, I think. But how? Who can help me please?
My code:
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// Show mesures
?>
<div class=”vc_col-sm-4 wpb_column vc_column_container”>
<div class=”vc_column-inner”>
“>
“>
<h3><span><?php the_title(); ?></span></h3>
</div>
</div>
<?php
endwhile;
else :
echo wpautop( ‘Sorry, no posts were found’ );
endif;