FIXED : How to fix Hueman theme & S&F filters function

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)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.