Forums › Forums › Search & Filter Pro › FIXED : How to fix Hueman theme & S&F filters function
- This topic has 1 reply, 2 voices, and was last updated 9 years, 6 months ago by Ross.
-
Anonymous(Private) May 19, 2015 at 1:30 pm #17869
A little while ago I had an issue with Hueman theme when using a custom archive page to display the S&F results page. When I was trying to use the filters without a keyword search, the theme would always return to the home/blog page and not the filtered results.
After many months of low knowledge code stumbling, I have found the issue and thought I would share. It appears that Hueman modifies the main query in some way, so I wrote a little function to remove the offending action and now S&F functions correctly
If you are using Hueman, try this in your theme functions.
function unhook_hueman_functions() {
remove_action( ‘pre_get_posts’, ‘alx_pre_get_posts’ );
}
add_action( ‘init’, ‘unhook_hueman_functions’ );This will affect including or excluding featured articles in the loop and I haven’t had a chance to look for a way to rewrite the theme hook rather than removing just removing it. If anyone can see a proper fix, I’d be very grateful for your suggestions. This is the function…
if ( ! function_exists( ‘alx_pre_get_posts’ ) ) {
function alx_pre_get_posts( $query ) {
// Are we on main query ?
if ( !$query->is_main_query() ) return;
if ( $query->is_home() ) {// Featured posts enabled
if ( ot_get_option(‘featured-posts-count’) != ‘0’ ) {
// Get featured post ids
$featured_post_ids = alx_get_featured_post_ids();
// Exclude posts
if ( $featured_post_ids && !ot_get_option(‘featured-posts-include’) )
$query->set(‘post__not_in’, $featured_post_ids);
}
}
}}
add_action( ‘pre_get_posts’, ‘alx_pre_get_posts’ );Thought this may help someone else or even the dev when trying to get themes to be compatible with S&F Pro.
๐
Ross Moderator(Private) May 21, 2015 at 1:05 pm #18014Sarah, many many thanks for sharing this back here ๐
I’m certain this will help other users, and I’m glad your up and running ๐
-
AuthorPosts