1

WordPress version: 5.4.1

I've built a plugin that includes a shortcode. The shortcode shows a product listing and has a couple of filters. The filters trigger a page refresh through JS with query params for the filter values. If I use the shortcode on any other page than the homepage, it works fine. If I add the shortcode to the homepage and apply a filter, somehow the blog homepage is shown instead of the regular front page. (Breadcrumbs show Home > Blog)

I've registred my query vars in the query_vars filter:

add_filter('query_vars', queryVars);
    function queryVars($vars){
        $vars[] = 'queryParam1';
        $vars[] = 'queryParam2';

        return $vars;
    }

The problem exists with registered query vars only, if I use any other var that is not recognized by the WP query var filter, it works fine.

I've searched for similar issues and found one issue with Relevanssi and a seemingly unfixed ticket in the core issue tracker: https://wordpress.org/support/topic/url-param-highlight-redirects-always-to-blog-page/ https://core.trac.wordpress.org/ticket/25143

Reading up on the ticket led me to believe the is_home propery on the WP_Query class is the problem. I've tried abusing the parse_query action just to see if changing some values fixes the issue, but it doesn't seem to change anything.

add_filter('query_param', parseQuery);
function parseQuery(\WP_Query $wpQuery)
    {
        if($wpQuery->is_home === true){
            $wpQuery->is_home = false;
            $wpQuery->is_archive = false;
            $wpQuery->is_front_page = true;
        }

        return $wpQuery;
    }

So far the only working thing I have come up with is just not using WP query vars but using $_GET, which is a very bad idea. What is causing this behavior and how can I bypass it?

My permalink setting is year/month/day/postname (second setting)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.