- This topic has 11 replies, 3 voices, and was last updated 5 years, 8 months ago by Leo.
-
AuthorPosts
-
August 10, 2018 at 12:40 pm #645261Carson
I am trying to disable post meta for certain authors.
Meaning, if author ID is “x”, I want no date, no name or any other meta to show up on the post itself as well as next to the preview in cetegory pages/wp show posts.Any ideas on how to achieve this?
Also, is there a way to get author bios under posts without a third-party plugin by now?
Thanks
August 10, 2018 at 1:27 pm #645276LeoStaffCustomer SupportHi there,
– Try this filter:
https://docs.generatepress.com/article/option_generate_blog_settings/Example is at the bottom of the page:
https://docs.generatepress.com/article/option_generate_blog_settings/Conditional tags you will need:
https://codex.wordpress.org/Conditional_Tags#An_Author_Page– As for author bio, should be able to use GP hooks:
https://docs.generatepress.com/article/hooks-overview/with the similar conditional tags as above.
I should also mention that Hooks Module will be replaced by Hooks Element in GP Premium 1.7 which should be released next Monday. My recommendation is to wait until Monday or becoming a beta tester (we are now on release candidate 3 so should be stable) so you can start using the new Hooks Element:
https://docs.generatepress.com/article/hooks-element-overview/
https://docs.generatepress.com/article/beta-testing/Let me know if this helps π
August 11, 2018 at 2:45 am #645567Carsonadd_filter( 'option_generate_blog_settings'{ if ( is_author( '4' ) ) { $options['read_more_button'] = true; $options['date'] = false; $options['categories'] = false; $options['tags'] = false; $options['comments'] = false; } return $options; }
Like this?
August 11, 2018 at 8:21 am #645759LeoStaffCustomer SupportNo that doesn’t look like the example at the bottom of the page.
add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' ); function lh_custom_author_page_settings( $options ) { if ( is_author( '4' ) ) { $options['read_more_button'] = true; $options['date'] = false; $options['categories'] = false; $options['tags'] = false; $options['comments'] = false; } return $options; }
Adding PHP: https://docs.generatepress.com/article/adding-php/
August 11, 2018 at 2:17 pm #645930CarsonThis doesn’t work. It still shows the author on the article.
To clarify:
Ideally I don’t want to show any author/date on the article istself, as well as on any previews in categories etc.
Code I am using right now:
add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' ); function lh_custom_author_page_settings( $options ) { if ( is_author( '3' ) ) { $options['author'] = false; $options['date'] = false; $options['categories'] = false; $options['tags'] = false; } return $options; }
August 11, 2018 at 7:10 pm #646024LeoStaffCustomer SupportThat should work for the archive/blog page.
For the article itself you will need the single_ filters like this:
https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98single_author%E2%80%99August 12, 2018 at 2:57 am #646174CarsonIt still doesnt work. The domain.com/category/xxxx page as well as the posts of the author with the ID 3, still show “by xxxxx”.
add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' ); function lh_custom_author_page_settings( $options ) { if ( is_author( '3' ) ) { $options['author'] = false; $options['single_author'] = false; $options['date'] = false; $options['categories'] = false; $options['tags'] = false; } return $options; }
August 12, 2018 at 10:17 am #646416TomLead DeveloperLead DeveloperTry this instead:
add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' ); function lh_custom_author_page_settings( $options ) { $author = get_the_author_meta( 'ID' ); if ( 3 === $author ) { $options['author'] = false; $options['single_author'] = false; $options['date'] = false; $options['categories'] = false; $options['tags'] = false; } return $options; }
Let me know π
August 12, 2018 at 3:55 pm #646570CarsonThanks a lot that works great!
So regarding the author boxes below posts, what code snippet do I have to add? And once hook elements is out it’s still the same snippet right?
Thanks again!
August 12, 2018 at 5:21 pm #646583LeoStaffCustomer SupportI believe we’d have to use this filter:
https://docs.generatepress.com/article/generate_hook_element_display/Can you open a new topic for this separate question?
It might be come in handy in the future π
Thanks!
August 13, 2018 at 1:45 am #646734CarsonSure!
August 13, 2018 at 8:06 am #647033LeoStaffCustomer SupportThanks π
-
AuthorPosts
- You must be logged in to reply to this topic.