Shortcode in Newscrunch
-
Hi there,
is it known that in the Newscrunch Theme, Shortcodes in posts are displayed publicly? For me, complete paths within the Shortcode are shown as well. I am using the Shortcode widget of the Gutenberg editor. Does anyone have a solution? There are also problems with pagination.
A few tips would be appreciated.The page I need help with: [log in to see the link]
-
Hi,@berndgoelden
We have checked the Newscrunch theme at our end, and the shortcodes are working fine.
Please try adding the shortcode directly inside a “Paragraph” or “Shortcode” block in the Gutenberg editor and check again. Also, ensure that the plugin providing the shortcode is active.
Could you please let us know which plugin’s shortcode you are using? This will help us test that specific shortcode at our end and assist you better.
Regarding the pagination issue, could you please clarify where it occurs — on the category/archive page or inside a single post using pagination (e.g., )? This will help us guide you more accurately.
Once we have this information, we’ll be happy to provide the exact fix.
Thanks and regards,
Support TeamHello,
it is correct that the shortcodes themselves do work. However, unfortunately, they are being displayed as plain text within my posts. Besides the “Downloadmanager” plugin, I am also using the “All in One Video Gallery” plugin. When I insert a shortcode into a post, it is executed, but it is also publicly visible as text within the post. For example, the entire path to the video is shown if it is present in the shortcode. This only happens in posts, not on a page. I’m using the shortcode widget in the Gutenberg Editor.
On this page, you can see a post where the shortcode is displayed:
https://goelden.de/category/mitgliederbereich/downloads/I really like your theme and have already tried several others today where this problem did not occur. It would be great if there were a solution and I could continue using your theme.
Best regards
B. Gölden-
This reply was modified 3 months, 3 weeks ago by
berndgoelden.
Hi,
By default, our theme displays the excerpt on blog and archive pages instead of the full content.
The excerpt doesn’t render shortcodes because doing so may affect the overall layout and design consistency of the archive pages.However, if you’d like to show the full content (including shortcodes) on archive pages, please follow the steps below:
- Go to your WordPress Dashboard → Appearance → Theme File Editor.
- Open the
content.phpfile located inside the theme folder >> template-parts folder>> open the file and find the below line of code on line no 107 - Find the line that looks like this:
<?php newscrunch_excerpt_fn(15); ?>- Replace it with:
<?php if ( is_archive() ) { the_content(); } else { newscrunch_excerpt_fn(15); } ?>- Update the file and refresh your archive page.
After this change, the full post content (including any shortcodes) will be displayed on archive pages.
Note: If you make this modification, ensure that your shortcodes are lightweight and don’t contain large or complex elements, as this may affect on the archive pages.
Feel free to reach out us for further assistance.
Thanks and regards,
Newscrunch Support TeamHi there.
Thank you very much, it worked. I already searched in the functions.php for the excerpt instruction.
I’ve tried at least 10 Themes in the last 2 Days, but now I’ll stick with yours.
Thanks again.
Best regardsHi again,
finally, I made a small change to the code snippet so that the shortcode disappears only in posts, but the full length of the posts is not displayed in the categories.
Regards, Here’s the code:<p class="spnc-description">
<?php
$excerpt = get_the_excerpt();
$excerpt = strip_shortcodes($excerpt);
echo apply_filters('the_excerpt', $excerpt);
?>
</p>Thanks again.
Hi @berndgoelden ,
I’m glad to hear that the issue has been resolved! We’re always committed to enhancing your website’s appeal. Should you need further assistance, please don’t hesitate to reach out.
If you’re satisfied with our theme and support, we’d greatly appreciate your feedback. Please take a moment to share your valuable thoughts here:
Regards
Newscrunch Support Team
Hi and hello again (positively),
I have another small snippet for you.
I just added it to your theme’s functions.php file.Recap: First, shortcodes were being displayed in posts. So, in content.php, I replaced
<?php newscrunch_excerpt_fn(15); ?>with
<?php
$excerpt = get_the_excerpt();
$excerpt = strip_shortcodes($excerpt);
echo apply_filters('the_excerpt', $excerpt);
?>This hides the shortcodes and ensures that posts are not displayed in full.
Afterwards, I added this snippet at the end of the theme’s functions.php, to make sure that the post excerpt length is set back to 15.
// Begrenzung der Beitragsvorschau-Länge (Excerpt) bei Newscrunch Theme
add_filter('excerpt_length', function($length) {
return get_theme_mod('post_excerpt_length', 15); // 15 Wörter als Standard, kann im Customizer geändert werden
}, 999);Maybe you could include this in the next update. If you hadn’t replied so quickly and shown me where the “excerpt” line was, I would still be searching today, or would have given up. Thanks again. Best regards.
Hi,
Sure, we’ll be happy to assist you with this.
But first, please let us know what specific issue you faced with the solution we provided earlier.If you only want to display the shortcode content for specific posts on the archive page, we can help you with that as well.
Thanks and Regards,
Support TeamHi,
The exact problem was that the shortcode was being displayed as raw text in your theme’s archive and category previews, but I did not want the shortcode to be shown there at all.Your initial code snippet did hide the shortcode, but it also displayed the entire post content in the preview, instead of a short excerpt.
We then edited the
content.phpand thefunctions.phpof the theme so that shortcodes are now not displayed in post previews anymore, and the excerpt length is set back to 15 words for better usability.It seems to be a bug in the theme that shortcodes are printed as text in previews/excerpts. In other themes, shortcodes are usually omitted or filtered out in the archive outputs.
Thank you for your help!
Hi,
Thank you for your detailed feedback.
We understand your concern — the shortcode was being displayed as raw text in the archive and category post previews, and you preferred not to have it shown there at all. The initial code snippet display shortcode output but also displayed the full post content instead of a short excerpt.
We’ve noted your feedback and will review this behavior in the theme to ensure shortcodes are properly filtered out in archive previews, with the excerpt displaying as expected.
Thank you so much for your cooperation and valuable suggestions.
Regards,
Support Team-
This reply was modified 3 months, 2 weeks ago by
Akhilesh.
-
This reply was modified 3 months, 3 weeks ago by
You must be logged in to reply to this topic.
