[Resolved] Dynamic Content – Excerpt – Missing options on dispaly?

Home Forums Support [Resolved] Dynamic Content – Excerpt – Missing options on dispaly?

Home Forums Support Dynamic Content – Excerpt – Missing options on dispaly?

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #2169103
    William

    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

    #2169107
    Leo
    Staff
    Customer Support

    Hi there,

    Can you take a look at this article first?
    https://docs.generatepress.com/article/excerpt-issues/

    #2169125
    William

    Aloha 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

    #2169217
    Fernando
    Customer Support

    Hi 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. πŸ™‚

    #2169258
    William

    Aloha 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

    πŸ™‚

    #2169329
    Fernando
    Customer Support

    That 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. πŸ™‚

    #2170352
    William

    Aloha 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?

    Single Post Items

    As always — the support I find here is second to none!

    – bill

    #2170372
    Ying
    Staff
    Customer Support

    Hi 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 πŸ™‚

    #2170402
    William

    ALoha Ying,

    1) Deactivated plugins (cleared cache, hard refresh, etc.) … no visual change.

    Deactivated plugins

    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

    #2170427
    Ying
    Staff
    Customer Support

    Hum.. 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 πŸ™‚

    #2170432
    William

    Aloha 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

    #2170435
    Ying
    Staff
    Customer Support

    You are very welcome πŸ™‚

    #2174998
    William

    Aloha 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

    #2175418
    David
    Staff
    Customer Support

    Hi 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.

    #2185436
    William

    Great stuff!!!

    Thank you David πŸ™‚

    – bill

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.