Last update at :2024-05-10,Edit by888u
In this way, it avoids the situation of a single article in the search list and a long sidebar; it also saves the user a second click, which can improve the user experience to a certain extent.
And we only need to add a piece of code to the theme function template functions.php.
//Jump to the article when there is only one article in the search results add_action('template_redirect', 'redirect_single_post'); function redirect_single_post() { if (is_search()) { global $wp_query; if ($wp_query->post_count == 1 && $wp_query->max_num_pages == 1) { wp_redirect( get_permalink( $wp_query->posts['0']->ID ) ); exit; } } }
Recommended site searches: domain name registration information query, website filing time, com domain name registration 1 yuan, domain name registration query US server website, free mysql space, domain name reservation, Chinese domain name fee, Qingdao ip agency, telecom hosting,
p>All copyrights belong to 888u unless special state
发表评论