如何根据WordPress中当前的每周日设置默认类别? [关闭]

  1. My site is comthainguyen.tk built with WordPress.
  2. You can see on left sidebar have Food Menu: Monday/TuesDay/... (this is Categories type).
  3. I want when users navigate to my Homepage URL (comthainguyen.tk), the category of current day will auto choose (click). I mean if today is Monday then Monday category will be chosen, and Tuesday then Tuesday category will be chosen, ....

I think you're thinking about this a tad wrong. You don't necessarily need/want to "auto-click" on the category. Just redirect to the appropriate category on based on the date.

Just make use the the current day with PHP's date() function, use wp_safe_redirect() to redirect to the category using the day you just got, and wrap that all with is_front_page() to make sure it's only fired if it's for the home page.

Now all requests to the home page will get redirected to the current days' category instead. Something like this should get you started:

add_action( 'template_redirect', 'load_category_by_day' );
function load_category_by_day(){
    if( is_front_page() ){
        $current_day = strtolower( date('l') ); // 'monday', 'sunday', etc.

        wp_safe_redirect( site_url( "/category/$current_day/" ) ); 
    }
}