Question: is there a way to hook into the post module query and add extra arguments without cloning and editing the module or core files?
I’m using facetwp for faceted search. They said you can use it with existing layouts and I’d love to use the bb module layouts in the post grid module.
I’ve set up the hook described in my functions.php file, added the class ‘facetwp-template’ to the posts module in the class field and have tried to clone the module into my theme per the instructions and place the recommended query argument in the post module’s frontend.php settings and just default it to true. For example, I tried this:
function search_filter($query) {
$query->set('facetwp', true);
}
it displays the posts from the posts module and doesn’t throw the “FacetWP was unable to auto-detect the post listing” error. However, it also doesn’t show the facets on the page.
When I update the args in the class-fl-builder-loop.php file as noted in the earlier thread post, it pretty much works: it shows the facets and the intial post results. However, when choosing a facet, it removes the post’s inline-style that makes it hidden. Not sure why, still debugging.
I see everything on facet selection. However, it’s doing something odd. Posting a link to it in my next comment. Let me know if you know what’s going on.
Right now, I’m still hacking the core file to get the facetwp argument in the loop (until the filter comes out). However, I fixed the content not showing up after a facet is checked.
This reinitializes the masonry-brick layout when any facet is triggered.
I still can’t get the pagination to work. Facetwp has their own pagination and so does the posts module. If you have any suggestions, I much appreciate it!
Right now, I’m still hacking the core file to get the facetwp argument in the loop (until the filter comes out).
No problem there. I’ve just pushed a commit with that filter so it will be in the next release.
I still can’t get the pagination to work. Facetwp has their own pagination and so does the posts module. If you have any suggestions, I much appreciate it!
Do you need to replace the post module’s pagination with theirs? If so, I have some ideas there.
Great! I’m thinking another filter is in order that will let you override the markup for the layout without having to override the entire module. That has actually been a fairly popular request, so we should get that done. Actually, it is I just pushed a commit that adds the fl_builder_posts_module_layout_path filter. To use that now, change this in the post module’s frontend.php file…
include $module->dir . 'includes/post-' . $settings->layout . '.php';
The fl_builder_posts_module_layout_path filter and fl_builder_loop_query_args filter were released in 1.7.6 earlier this week. Have you upgraded to that yet?