登陆加密和搜索跳转

以上说的功能需要通过修改配置文件来实现。

文章页面跳转和搜索跳转:

WordPress 文章页跳转需要安装 Page Links To 实现, 搜索文章当只搜到一条直接跳转通过修改 functions.php 配置文件添加以下代码实现。

/** Search Post Go **/
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;
 }
 else if ($wp_query->post_count == 0 && $wp_query->max_num_pages == 0) {
 header('Location:https://badpuck.com');
 exit;
 }
 }
}

设置指定登陆链接:

WordPress 设置指定登陆链接,当不是通过指定链接访问登陆将跳转到指定地址,通过修改 functions.php 配置文件添加以下代码实现。

/** login **/
/** http://wordpress.com/wp-login.php?pass=fuck **/
add_action('login_enqueue_scripts','login_protection');function login_protection(){if($_GET['pass'] != 'fuck')header('Location:https://badpuck.com');}