- This topic has 27 replies, 5 voices, and was last updated 5 years, 11 months ago by
Leo.
-
AuthorPosts
-
September 26, 2017 at 1:17 am #392053
themedleb
I tested it and it worked (You missed the closing of the 8th line though).
Thank you.
September 26, 2017 at 8:05 am #392274Tom
Lead DeveloperLead DeveloperAwesome!
Technically it doesn’t need an opening or closing as it’s a one line conditional, but I’ve added it in there for good coding standards 🙂
September 26, 2017 at 3:12 pm #392511themedleb
Okay, just because I tried to put the code on the “Snippet” plugin, and after clicking on the “Save changes” button this appeared:
Don’t Panic
The code snippet you are trying to save produced a fatal error on line 8:
syntax error, unexpected ‘;’, expecting ‘,’ or ‘)’
The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.
Anyway, thank you so much for your help and support, never thought I could make such things with your product/products.
September 26, 2017 at 7:42 pm #392578Leo
StaffCustomer SupportLooks like it’s missing a closing bracket.
I’ve edited it. Try it again 🙂
September 26, 2017 at 8:21 pm #392597themedleb
I did thank you.
September 26, 2017 at 10:08 pm #392634Leo
StaffCustomer SupportNo problem!
May 17, 2018 at 10:30 pm #578555Damon
This looks really close. Only issue I see is that this is happening on the author page, when there are no posts there. So there are in fact posts. Just none showing on the author page.
May 18, 2018 at 9:03 am #578955Leo
StaffCustomer SupportHi Damon,
Not quite sure what you mean.
Any chance you can open a new topic and provide a link to your site with a bit more details?
Thanks!
May 18, 2018 at 9:56 am #578995Damon
Thank you Tom. That code is close, but not quite working since this is an author page. I’m guessing this is because there are in fact posts, but none yet by this author.
Here’s the page, until the author creates a first post:
https://www.dropbox.com/s/h0xjsrcuo1xtkhm/1.png?dl=0Here’s the page after the first post:
https://www.dropbox.com/s/gcvlipa0l2a34k8/2.png?dl=0I’m trying to redirect that first confusing page to another page that has instructions for creating a first post.
May 18, 2018 at 10:18 am #579014Leo
StaffCustomer SupportHi Damon,
I don’t think you are replying to the correct post here.
May 18, 2018 at 10:52 am #579044Damon
Ack, sorry about that. Yes, please close this topic.
April 29, 2020 at 5:26 am #1261021Alain Aubry
Thank you, this helped to sort a similar situation, related to a specific CPT
// Redirect 404 errors of specific CPT "eventos" add_action( 'template_redirect', 'tu_redirect_no_results' ); function tu_redirect_no_results() { global $wp_query; if ( 0 === $wp_query->post_count && $wp_query->query['post_type'] == 'evento' ) { wp_redirect( site_url( '/sem-eventos' ) ); } }I am talking of this: https://generatepress.com/forums/topic/logo-on-mobile-menu/#post-392010
April 29, 2020 at 9:27 am #1261551Leo
StaffCustomer SupportThanks for sharing your solution!
-
AuthorPosts
- You must be logged in to reply to this topic.