Tuesday, September 6, 2022
HomeWordPress DevelopmentRedirect Creator Archive to Customized Put up Kind With Question Vars?

Redirect Creator Archive to Customized Put up Kind With Question Vars?


I’m making an attempt to determine the right way to change the creator archives web page with a customized submit sort web page if one exists for that creator utilizing question vars (or another technique if question vars is not one of the best ways) – I’ve a whole lot of authors so as to add so redirecting each manually is absolutely not very best.

It is a snippet that replaces class archives with a web page if the web page permalink construction matches – I mainly want to obtain the identical factor however for creator pages to get replaced by a customized submit sort (on this case “bio” is the slug).

 add_filter('request', operate(array $query_vars) {
// do nothing in wp-admin
if(is_admin()) {
    return $query_vars;
}
// test if the question is for a class archive
if(isset($query_vars['category_name']) && !isset($query_vars['name'])) {
    
  //generate the web page path
    $pagename="class/" . $query_vars['category_name'];
    
  //try and load the web page matching the $pagename slug
    $web page = get_page_by_path( $pagename , OBJECT );

 if ( isset($web page) ){
    // utterly change the question with a web page question
    $query_vars = array('pagename' => "$pagename");
 }
}
return $query_vars;

Any recommendations on customizing the code above to work for this? Perhaps there’s a higher method of doing this? I believe I additionally must in some way match on this however I can not seem to get the fitting order or syntax:

$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($creator));

Respect any concepts and even tips to assets for what would educate me the right way to perceive this higher.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments