Hello friends. I think I missed the title. I apologize. The moderator can change if necessary.
What I need is to “change the route of the links”. Something like.
I got what I wanted using the code below. I don’t know if it’s ideal, but it worked. The page is given priority when using the link with the slug similar to the author’s nickname.
I don’t want to use the author’s page, because I created the page for him. So the slug is the same. However, before typing / slug I opened the author’s page instead of the page.
add_action( 'init', 'wpse16902_init' );
function wpse16902_init() {
$GLOBALS['wp_rewrite']->use_verbose_page_rules = true;
}
add_filter( 'page_rewrite_rules', 'wpse16902_collect_page_rewrite_rules' );
function wpse16902_collect_page_rewrite_rules( $page_rewrite_rules )
{
$GLOBALS['wpse16902_page_rewrite_rules'] = $page_rewrite_rules;
return array();
}
add_filter( 'rewrite_rules_array', 'wspe16902_prepend_page_rewrite_rules' );
function wspe16902_prepend_page_rewrite_rules( $rewrite_rules )
{
return $GLOBALS['wpse16902_page_rewrite_rules'] + $rewrite_rules;
}
A possible solution would be to disable author.php completely, but without redirection. Disable completely. But I couldn’t do that. All the code I found disables author.php, but redirects it. So it still exists, although it is hidden. Anyway, the code above helped me. I just ask now if it is ideal.
-
This reply was modified 4 years, 9 months ago by
wpforever18.