- This topic has 15 replies, 5 voices, and was last updated 1 year, 11 months ago by David.
-
AuthorPosts
-
March 27, 2022 at 1:49 pm #2169103William
Aloha π
I’ve built a Block Element >> Content Template for a Catagory Archive display.
I added a Dynamic Content block to display Excerpts.
The excerpts display fine, but neither the Excerpt length (option not having any effect) and ‘Read More’ (‘Use theme more link’) link are showing up.
https://cssopps.flywheelsites.com/watermelon/
Any guesses?
Million thanks as always for your assistance π
– bill, University of Hawai’i
March 27, 2022 at 1:50 pm #2169107LeoStaffCustomer SupportHi there,
Can you take a look at this article first?
https://docs.generatepress.com/article/excerpt-issues/March 27, 2022 at 2:22 pm #2169125WilliamAloha Leo,
Thanks for the link – sorry for not digging deeper here … figured it was just me struggling as usual.
I ‘activate the read more label’ with your code snippet – worked π
https://docs.generatepress.com/article/activating-read-custom-excerpt/
—
Word count still not working … I have the Correct Post Format: Standard.
I tried the More button – not sure if it applies in this case – but it had no effect
Thank you again!
bill
March 27, 2022 at 7:28 pm #2169217Fernando Customer SupportHi Bill,
The Excerpt Word count functionality works if this field is left empty: https://share.getcloudapp.com/E0uoODb6
It doesnβt work if there is a Custom Excerpt set.
Can you try leaving it blank and see how it goes? π
Hope this clarifies. π
March 27, 2022 at 8:51 pm #2169258WilliamAloha Fernando,
That does indeed work … but I’m using the custom Excerpt specifically to get the exact language I want to display, rather than an auto-pulled chunk by WordPress.
Should I just rethink the way I work?
ie. just make sure that the first sentence or two (depending on final Word count) is what I want to appear on archive pages?
Any other strategies?
Thanks again for your weekend help!!
bill
π
March 27, 2022 at 11:49 pm #2169329Fernando Customer SupportThat would be one option.
Another option is to make sure that the count of the words in the custom excerpt wouldnβt exceed your preference. In other words, you can try using a word counter before placing the custom excerpt.
Example: https://wordcounter.net/
Lastly, instead of the steps above, you can also try adding this PHP snippet to manually trim the length of your custom Excerpt:
function my_trim_excerpt_test($post_excerpt){ if( ( is_archive() || is_home() ) && ! is_admin() ) { return wp_trim_words( $post_excerpt, 4); } return $post_excerpt; } add_filter( 'the_excerpt', 'my_trim_excerpt_test');
Kindly replace
4
with your preferred word count.Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
Adding it through Code Snippets should work.
Hope this helps. π
March 28, 2022 at 1:40 pm #2170352WilliamAloha Fernando,
That snippet was exactly what I needed π THANK YOU!!
Much appreciated!
—
Last Q: Any chance you could tell me how to get rid of these two items at the bottom of a SINGLE POST?
As always — the support I find here is second to none!
– bill
March 28, 2022 at 2:01 pm #2170372YingStaffCustomer SupportHi Bill,
It looks like something inserted with a hook element/ block element – hook or something generated by a plugin.
Can you try:
1. Deactivate all plugins except GP premium.
2. If it’s still there, go to appearance > GeneratePress, deactivate elements module.
3. If step 2 works, re-activate the elements module, go to appearance > elements, check which element is inserting this content.
Let me know if this helps π
March 28, 2022 at 2:39 pm #2170402WilliamALoha Ying,
1) Deactivated plugins (cleared cache, hard refresh, etc.) … no visual change.
2) Deactivated elements module (cleared cache, hard refresh, etc.) … no visual change.
hmmmmmmm … I did just create a NEW test post and the two unwanted elements are gone?!?
http://cssopps.flywheelsites.com/apple/test/
Any idea how I might strip these items off older POSTS?
http://cssopps.flywheelsites.com/apple/apple-frank/
Thank you Ying!!
– bill
March 28, 2022 at 2:52 pm #2170427YingStaffCustomer SupportHum.. that’s difficult to tell as we haven’t found out what is adding the content.
Any chance you can provide admin access so we can have a look at the backend?
Please keep the plugins deactivated.
Let me know π
March 28, 2022 at 2:59 pm #2170432WilliamAloha Ying … I was just about to write back.
No need to bother you all with this one … π
My best guess is that I duplicated and modified the original “Hello World’ post.
Fresh blank POSTS are working fine … I’ll just go ahead and redo them.
But thanks a million for your assistance!
Have a terrific week!
– bill
March 28, 2022 at 3:01 pm #2170435YingStaffCustomer SupportYou are very welcome π
April 1, 2022 at 1:18 pm #2174998WilliamAloha again π
So sorry to re-open this one … I had a quick follow-up.
Fernando offered this code to manually trim excerpts on my archive pages:
function my_trim_excerpt_test($post_excerpt){ if( ( is_archive() || is_home() ) && ! is_admin() ) { return wp_trim_words( $post_excerpt, 4); } return $post_excerpt; } add_filter( 'the_excerpt', 'my_trim_excerpt_test');
and it works great!
Is there a way to adjust the code to trim a custom text field called ‘general_description’ ?
Happy Friday!!!!
– bill
April 2, 2022 at 4:22 am #2175418DavidStaffCustomer SupportHi there,
if its a GP Dynamic text field then you could do this:
1. Select the headline block that is displaying the dynamic text, and in Advanced > Additional CSS CLass(es) give it a custom class eg.
your-custom-class
2. Add this PHP Snippet:
add_filter( 'generate_dynamic_element_text', function( $text, $block ) { if ( ! empty( $block['attrs']['className'] ) && 'your-custom-class' === $block['attrs']['className'] ) { $text = wp_trim_words( $text, 4); } return $text; }, 10, 2 );
Make sure to update the
your-custom-class
in your code to match.April 11, 2022 at 11:33 am #2185436WilliamGreat stuff!!!
Thank you David π
– bill
-
AuthorPosts
- You must be logged in to reply to this topic.