- This topic has 7 replies, 3 voices, and was last updated 4 years, 11 months ago by
David.
-
AuthorPosts
-
March 18, 2021 at 4:43 am #1700106
JC
Hello,
I think I have found the solution for one of my problems but just want to confirm.
Issue 1 is when Excerpt field is filled in, custom excerpt, it does not display on category views so will this solve it?: https://docs.generatepress.com/article/activating-read-custom-excerpt/
Issue 2, displaying the custom excerpt (as added to excerpt field during post edit) on a post and changing it to H2. What is the best way to go about this without adding any additional plugins or altering the theme files.
I do have the paid version so can this be done via ELEMENTS if so any help/direciton would be apprediated 🙂
March 18, 2021 at 5:45 am #1700170JC
For ISSUE 2, I have tried this:
add_action('generate_after_entry_header', 'db_single_post_excerpt'); function db_single_post_excerpt() { if ( is_single() && has_excerpt() ) { $single_excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $post_id)); echo '<div class="single-excerpt">' . $single_excerpt . '</div>'; } }The only issue is the image is set to display below title (Customiser/Layout/Blog) but now I get the Excerpt first then image, I want it below the image and not before.
March 18, 2021 at 6:40 am #1700266David
StaffCustomer SupportHi there,
1. Yep thats correct.
2. In that code try changing the first line ie.add_action('generate_after_entry_header', 'db_single_post_excerpt');to:
add_action('generate_after_entry_header', 'db_single_post_excerpt', 50);March 18, 2021 at 11:04 am #1700833JC
Thank you David. Just for the sake of learning what does the 50 represent? That sets it to priority 50, right?
March 18, 2021 at 2:47 pm #1701040Leo
StaffCustomer SupportYes exactly 🙂
June 30, 2021 at 6:12 am #1839648JC
Hello,
So I have this setup:
add_action('generate_after_entry_header', 'db_single_post_excerpt', 50); function db_single_post_excerpt() { if ( is_single() && has_excerpt() ) { $single_excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $post_id)); echo '<div class="single-excerpt"><h2>' . $single_excerpt . '</h2></div>'; } }The problem is that the output is this;
<h2><p>excerpt text</p></h2>I don’t want the Paragraph elements in there it must only be in the H elements. What am I doing wrong or how can I do this better maybe by setting it up via ELEMENTS?
June 30, 2021 at 6:20 am #1839653JC
I feel so enabled… I solved it with a bit of Googling and luck so sharing.
I changed:
the_excerpt
to
get_the_excerptSo the output is now without the paragraph elements for the excerpt. 🙂
/** excerpt on post and wihtout paragraph elements **/ add_action('generate_after_entry_header', 'db_single_post_excerpt', 50); function db_single_post_excerpt() { if ( is_single() && has_excerpt() ) { $single_excerpt = apply_filters('get_the_excerpt', get_post_field('post_excerpt', $post_id)); echo '<div class="single-excerpt"><h2>' . $single_excerpt . '</h2></div>'; } }June 30, 2021 at 6:55 am #1839686David
StaffCustomer SupportGlad to hear you found the solution 🙂 And thanks for sharing!!!
-
AuthorPosts
- You must be logged in to reply to this topic.