Tell us what you are trying to do?
Hi to all,
so, I'm building a new theme to my Event Site using Toolset, View, Form, Block editor in Content Template and sometimes Divi.
Because I don't use Block plugin but I use View, for me, it is not too fast building the Author Posts Archive content template without using Toolset Content Template section...
Well, I have created a new CPT called "Autore", and with Content Template I have create the "Autore" single page layout. With View I permit to every Author to create only one CPT "Autore" single post.
Using the following custom code, I have redirected the Author Posts Archive Page to the relative CPT "Autore" single post where I display the general information about the Author and a search filter with the posts list, and with another plugin I will redirect the Authors Archive to the CPT "Autore" Archive.
In every Event post, I have added a link to the Author Post Archive that with the following code is redirect to its relative CPT "Autore" single post.
Now, here, the custom code I have mentioned above:
add_action( 'template_redirect', 'redirect_author_archive_to_staff_profile' );
function redirect_author_archive_to_staff_profile() {
if ( is_author() ) {
$author = get_the_author_meta('ID');
if($author) {
$args = array(
'author' => $author,
'post_type' => 'autore',
'post_status' => 'publish',
'posts_per_page' => 1
);
$author_posts = new WP_Query( $args );
if( $author_posts->have_posts() ) {
while( $author_posts->have_posts() ) {
$author_posts->the_post();
$author_bio_post = get_the_ID();
$authorProfileUrl = get_permalink($author_bio_post);
}
wp_reset_postdata();
}
}
wp_redirect( $authorProfileUrl, 301 );
exit;
}
}
Now, because my site is populated with more Events posts and more Authors, for the existing authors, on clicking the link to them Author Posts Archive that not have created them CPT "Autore" single post, the redirection returns a White Page...
Is it possible, for Every Authors that not have created them CPT "Autore" single post, when they try to create new Event post or login into the site (the registration and login are managed by Indeed Ultimate Membership Pro) to be redirected to the CPT "Autore" single post Creation FORM?
Is there any documentation that you are following?
I don't know.
Is there a similar example that we can see?
I don't know.
What is the link to your site?
This link is my CPT "Autore" single post: lien caché
but the original Author Post Archive is lien caché
This is the link about another Author Post Archive that not has created his own CPT "Autore" single post that is redirect to white page: lien caché