- This topic has 10 replies, 4 voices, and was last updated 1 year, 11 months ago by
epickenyan.
-
AuthorPosts
-
May 10, 2019 at 1:07 am #894924
Joseph
I have certain categories that I do not want to show the author and date. I looked at the PHP documentation and found this for the date removal. How or does this also apply to the removal of the author?
add_filter( ‘generate_post_author_output’, function( $output ) {
// If we’re on our “my-post-type” post type, remove the author.
if ( is_post_type_archive( ‘my-post-type’ ) || ‘my-post-type’ == get_post_type() ) {
return ”;
}// Otherwise, display it.
return $output;
} );Thank you in advance.
May 10, 2019 at 3:22 am #895033David
StaffCustomer SupportHi there,
maybe this article will be helpful:
https://docs.generatepress.com/article/option_generate_blog_settings/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 10, 2019 at 7:15 pm #895836Joseph
I crashed the site adding the script to the themes.php. Got it back up. Can you assist with the proper code? The category I am looking to eliminate the author and date is American Heritage Center.
Thanks David, any help is appreciated.May 11, 2019 at 9:14 am #896348Tom
Lead DeveloperLead DeveloperHi there,
Try this:
add_action( 'wp', function() { if ( is_category( 'your-category-slug' ) ) { add_filter( 'generate_post_date', '__return_false' ); add_filter( 'generate_post_author', '__return_false' ); } } );
Just replace
your-category-slug
with your category.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 11, 2019 at 12:29 pm #896504Joseph
Hi Tom, added the script and got the message at the very bottom of the attached image I have enclosed. Pretty straight forward but something is not working. I probably missed something.
May 11, 2019 at 5:15 pm #896627Tom
Lead DeveloperLead DeveloperI believe that means WordPress isn’t communicating with the files well enough to update them.
You could try using a plugin like Code Snippets instead if you can’t access the files via FTP.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 11, 2019 at 11:00 pm #896719epickenyan
Hi Tom. How about hiding the author byline in a certain category across the site? I have a guest category and I am hiding the byline in single posts using CSS like
.category-category name .byline{display: none;}
and the above function in code snippets didn’t work.Update: Tried this code and it worked. Hope it is a correct code?
add_action( 'wp', function() { if ( has_category( array( 10 ) ) ) { add_filter( 'generate_post_author', '__return_false' ); } } );
May 12, 2019 at 8:16 am #897031Tom
Lead DeveloperLead DeveloperThat’s perfect 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 12, 2019 at 12:14 pm #897212epickenyan
Thanks…
May 12, 2019 at 2:57 pm #897285Joseph
Epic, thank you much!! That worked perfectly!!
May 12, 2019 at 7:47 pm #897396epickenyan
You are welcome. I justly slightly modified a code shared by Tom in another post.
-
AuthorPosts
- You must be logged in to reply to this topic.