0

I want to implement a page, let's say /today-deals that will show all posts under today category, like if we were navigating to /category/deals-for-october-31-2018 but without changing the URL.

0

I achieved it using template_include hook:

add_filter(
    'template_include',
    function ($template) {
       if (is_page('today-deals')) {
                global $wp_query;
                $wp_query = new WP_Query( array( 'category_name' => date('Ymd') ) );
                $template = 'category.php';
        }


        return $template;
    }
);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.