I am trying to:
have the [wpv-post-excerpt] shortcode not to strip off html from the original excerpt, to do this I tried to use both these codes:
https://toolset.com/forums/topic/how-can-i-display-paragraphs-in-an-excerpt/
// Rewrite the excerpt settings
// <em><u>hidden link</u></em>
function get_excerpt($text) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace('\]\]\>', ']]>', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = strip_tags($text, '<p><a><img>');
$excerpt_length = 200;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '...');
$text = implode(' ', $words);
$text = force_balance_tags( $text );
}
return $text;
}
// make new settings work if you are using [wpv-post-excerpt] shortcode of Views plugin
add_shortcode('full-post-excerpt', 'get_excerpt');
This instead of showing the short description shows the page content
https://toolset.com/forums/topic/views-strip-out-html-markup-form-excerpt/#post-9514
// Rewrite the excerpt settings
// <em><u>hidden link</u></em>
function custom_excerpt($text = '') {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
// $text = strip_shortcodes( $text );
$text = do_shortcode( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
// make new settings work for WordPress
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
add_filter( 'get_the_excerpt', 'custom_excerpt' );
// make new settings work if you are using [wpv-post-excerpt] shortcode of Views plugin
remove_shortcode('wpv-post-excerpt');
add_shortcode('wpv-post-excerpt', 'get_the_excerpt');
This one does not do anything
Link to my site:
hidden link
I expected to see:
I expect to have the line braks and paragraph in their places
Instead, I got:
What I wrote above.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Raphael,
Thank you for contacting our support forum.
Actually we are in a bind here since the wordpress default does not allow for HTML in the excerpt field and it will be stripped out when displaying on the frontend.
Might I suggest a much simpler approach my creating a custom WYSIWYG field in Types and allow this to be your excerpt field. This will allow you to format your texts anyhow you like.
Thanks,
Shane
Hi Shane,
sorry to bother u again... many treads from me lately.
What exaclty do you mean by adding a custom WYSIWYG in Types, to what I have to add it?
Should I have created a custom product type, instead of using standard Woocommerce product type?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Raphael,
No worries we are here to help no matter the issue 🙂
Lets see, what i'm saying is to create a custom WYSIWYG field in Types, this field is similar to the default wordpress editor that would allow you to add your text with the formatting.
I'm suggesting to use a custom field like this instead of using the excerpt field from wordpress which doesn't allow you to add formatting.
Thanks,
Shane
Thanks Shane,
yes, that seams to be a good idea.
How do I add, from types this kind of field? And to what I should have to add it?
After I will add it, should I have to copy paste all products excerpt over there?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Raphael,
To add this field you will go to Types -> Post Field and add a new Post Group for Products.
Here is a more detailed document on how to do this.
https://toolset.com/documentation/user-guides/using-custom-fields/
Thanks,
Shane
Hi Shane,
I've added that field from types, WYSIWYG.
I've copied the content of the excerpt field to the newly created field, but still the line breakings are stripped off.
You can see this link
hidden link
which has the excerpt filed switched to the new one
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Raphael,
The issue should be resolved now. It was that the content template was set to "Disable Automatic Paragraphs" This means that you will need to manually add p tags, however unchecking this settings allow the automatic paragraphs to be added.
Thanks,
Shane
Thx Shane,
sorry I didn't noticed that.
Is there any way to migrate content of a field inside another one?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Raphael,
Maybe through some custom code its possible but I believe manually would be the way to go since custom coding this would be out of our support scope.
Thanks,
Shane