-
netkant
Hi!
I am setting an excerpt length in the the Loop Item inside of a Query and Looper element. However it seems to have no effect no matter what number i type in. Is there a known feature with this feature or perhaps i am understanding the wording wrong?: “Enter the number of words to display in the excerpt. If empty, the default theme behavior is used.”
I am trying to create the effect of showing some of the excerpt and then the rest being cut off, so you have to enter the post to see it all.
The tag that is inserted in the loop item is this: “{{post_excerpt length:5}}”. However it still shows the entire excerpt.
-
Hi there,
Did you add a Read more tag to the post content, or did you add a custom excerpt to the post?
-
netkant
Hi,
The text is a normal post excerpt. Added in the right column of a post. The excerpt is also shown fine, it just isnt being cut off with the “length” attriute.
-
Alvind
Hi there,
The excerpt length setting won’t work if the excerpt is added through the custom excerpt field, unfortunately.
However you can try this workarond. Add this snippet:
add_filter('generateblocks_dynamic_tag_output', function ($output, $options) { if (isset($options['custom_excerpt_length'])) { if (!empty($output)) { $num_words = !empty($options['custom_excerpt_length']) && is_numeric($options['custom_excerpt_length']) ? intval($options['custom_excerpt_length']) : 3; return wp_trim_words($output, $num_words, '...'); } } return $output; }, 10, 2);
Then use this dynamic tag: {{post_excerpt custom_excerpt_length:5}}
-
netkant
This works, thank you!
-
Alvind
You’re welcome!
- You must be logged in to reply to this topic.