- This topic has 8 replies, 2 voices, and was last updated 2 months, 3 weeks ago by
Fernando.
-
AuthorPosts
-
October 19, 2022 at 10:57 am #2379091
VR
Hello,
Per GP Support’s request, I am following up on posts in this thread (Post ID #2379026):
I’ve placed the Search Results page URL in the private info box on this post.
Thanks!
January 3, 2023 at 1:27 pm #2482702VR
Hello,
I am moving the questions from another thread (still unanswered) here so everything is in one place:
–> Prior thread URL: https://generatepress.com/forums/topic/automatic-excerpts-and-the-manual-read-more-tags-looping-in-harmony/#post-2378101
Two more questions: 1) Is there a way to adapt the code above (post #2337324) to also work for the default Search Results post excerpts? They don’t use the “GB Headline block” so the code doesn’t work for them. Know we can create a whole new Search Results template, per https://generatepress.com/forums/topic/design-search-page/, but since the only change we need is displaying dynamic excerpts when the <!–more–> link exists in the post content, would rather not have to create a whole new template to achieve that. 2) For static WP Pages – Is it possible to add a snippet to also include an auto-generated excerpt on the Search Results page? Or, will the client need to add a manual custom excerpt if they want text to appear for Pages, too? Thanks!
Still looking for help with the above two items. Here’s a sample Search Results page showing the <!–read more–> link text is NOT rich-text on the Results page: https://jillk5.sg-host.com/?s=meeting
I’ve placed admin credentials for the site in the Private Info box.
Thank you!
January 3, 2023 at 7:14 pm #2482912Fernando Customer Support
Hi VR,
Let’s try to address #1 first.
Can you try adding this PHP snippet?:
add_filter( 'generate_show_excerpt', function( $show ) { global $post; if ( strpos( $post->post_content, '<!--more-->' ) && is_search() ) { return false; } return $show; } );
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
January 4, 2023 at 1:33 pm #2483943VR
Terrific. thank you! That takes care of Item #1.
For Item 2 – as seen in the Search Results page here: https://jillk5.sg-host.com/?s=meeting
… the “About” and “Home” pages do not auto-generate a summary using the existing body text on the page. Any help you can provide to automate this (when no manual excerpt exists) rather than having the Client have to manually create excerpts for all pages would be much appreciated.January 4, 2023 at 5:20 pm #2484049Fernando Customer Support
This is WordPress core already. Can you try adding this Snippet first?:
add_post_type_support( 'page', 'excerpt' );
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
January 5, 2023 at 1:16 pm #2485117VR
Thanks. We added the snippet and can now see the Excerpt option in the right sidebar of Pages. It doesn’t seem to be auto-creating an excerpt, though, if none exists in the Search Results page, tho (see “About” page):
https://jillk5.sg-host.com/?s=meeting
Interestingly, the “Home” page does appear to display the Headlines from the current Home page (“NEXT MEETING LATEST NEWS”), but nothing else.
Question: Will the client have to enter manual excerpts for all pages they want content to appear in Search Results and other Index type pages?
Thanks for your help!
January 5, 2023 at 5:41 pm #2485294Fernando Customer Support
If your text is not in a Grid or nested under multiple Blocks, the excerpt for pages should be automated. Otherwise, you’ll need to add a manual excerpt.
It’s a core WordPress issue. The excerpt function doesn’t parse nested blocks’ content. You will have the same issue if you use a core Group Block.
As mentioned, the workaround is to use a Manual Excerpt in your posts. So to answer your question, for pages like your About Page, with how it’s structured, yes, your client needs to add a manual excerpt.
January 7, 2023 at 7:48 am #2486983VR
Okay, gotcha. Thanks for the clear explanation. We’ll move ahead with manual excerpts and hope that WordPress core resolves the issue in a future update.
Thank you!
January 8, 2023 at 5:05 pm #2488279Fernando Customer Support
You’re welcome, VR!
-
AuthorPosts
- You must be logged in to reply to this topic.