- This topic has 13 replies, 3 voices, and was last updated 5 months, 1 week ago by
Ying.
-
AuthorPosts
-
March 8, 2022 at 5:06 am #2146522
Daniele
Hello,
how can I disable excerpt on custom post type archives?Is there also a way to show categories under the posts?
thank you
March 8, 2022 at 5:49 am #2146569David
StaffCustomer SupportHi there,
the easiest method is to use a Block Element – Content Template:
https://docs.generatepress.com/article/block-element-content-template/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 8, 2022 at 8:29 am #2146945Daniele
Hi David,
I prefer not installing generateblocks, I aiming to maximum speed in this website.
Is there any filter I could use?March 8, 2022 at 8:41 am #2146959David
StaffCustomer SupportOf course we have filters 🙂 Just a note though GB won’t affect your sites performance as it simply outputs the necessary HTML and CSS required 🙂
Remove the excerpt by settings length to 0 with this filter:
https://docs.generatepress.com/article/excerpt_length/#examplesExample of applying that to a specific CPT:
function db_cpt_excerpt_zero($length) { global $post; if ($post->post_type == 'your-post-type') { $length = 0; } return $length; } add_filter('excerpt_length', 'db_cpt_excerpt_zero', 100);
And this to add meta to your post type:
https://docs.generatepress.com/article/generate_entry_meta_post_types/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 8, 2022 at 8:49 am #2146972Daniele
Thanks,
for the read more button? I have to remove it with css?For the meta now I see only data and author, but I’m interested in categories
Regarding the plugin, it does not load any extra CSS or JS?
March 8, 2022 at 8:54 am #2146977David
StaffCustomer SupportYou can use the option_generate_blog_settings filter to effectively change any blog setting for a specific condition:
https://docs.generatepress.com/article/option_generate_blog_settings/
eg.
add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' ); function lh_custom_search_results_page_settings( $options ) { if ($post->post_type == 'your-post-type') { $options['read_more_button'] = false; } return $options; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 8, 2022 at 9:00 am #2146985Daniele
mmm..is not working with this:
add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' ); function lh_custom_search_results_page_settings( $options ) { if ($post->post_type == 'progetti') { $options['read_more_button'] = false; $options['date'] = false; } return $options; }
March 8, 2022 at 9:08 am #2146995David
StaffCustomer SupportTry this method instead:
add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' ); function lh_custom_search_results_page_settings( $options ) { if ( 'progetti' === get_post_type() && ! is_singular() ) { $options['read_more_button'] = false; $options['date'] = false; } return $options; }
If you can make sure the
progetti
name i added is correct.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 8, 2022 at 9:11 am #2147007Daniele
With this:
add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' ); function lh_custom_search_results_page_settings( $options ) { if ( 'progetti' === get_post_type() && ! is_singular() ) { $options['read_more_button'] = false; $options['date'] = false; $options['categories'] = true; $options['author'] = false; } return $options; }
read more buttons is still present, and Catagories are not visible
date and author works fineMarch 8, 2022 at 9:21 am #2147018David
StaffCustomer SupportYou need to use this option for the read more:
$options[‘read_more’]
Is the other meta for the archives or the single post ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 8, 2022 at 9:22 am #2147019Daniele
I am on the archive, this is the page: https://dev1.oceandigitals.com/portfolio/
March 8, 2022 at 11:05 am #2147140Ying
StaffCustomer SupportHi Daniel,
I’m not seeing read-more/date/author on your archive page:
https://www.screencast.com/t/onqvDgmCg9aFor the categories, add this PHP snippet to activate the footer meta for your custom post type:
add_filter( 'generate_footer_meta_post_types', function( $types ) { $types[] = 'progetti'; return $types; } );
March 9, 2022 at 1:09 am #2147682Daniele
Perfect, it is working now!
March 9, 2022 at 10:29 am #2148543Ying
StaffCustomer SupportGlad to hear that 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.