Forums Forums Search & Filter Pro FIXED : How to fix Hueman theme & S&F filters function

Tagged: , , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Anonymous
    #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
    #18014

    Sarah, many many thanks for sharing this back here ๐Ÿ˜€

    I’m certain this will help other users, and I’m glad your up and running ๐Ÿ™‚

Viewing 2 posts - 1 through 2 (of 2 total)