How to stop excerpt stripping html tags

I’m using the PODS plugin to create custom post types, and one of the features of Pods is the ability to create templates (not Wordpress templates) for displaying the custom post types. When I created an template for my custom post type, when I display the archive page, all the HTML is stripped out.

On researching this, and searching the support forum here, I noticed that one of the responses on something unrelated mentioned that html tags are stripped out of excerpts, and I suspect that’s the problem. I’m guessing that the custom post type template is running through the excerpts filter on the archive pages.

Is there any way to stop it from stripping out the html? I’m comfortable working in php and have a child theme already. But it would help me if you could point me in the right direction for how to start.

Here’s an example of what’s happening:
https://www.mdprogressivecaucus.com/membergroups/

Here’s what it should look like:
https://www.mdprogressivecaucus.com/groups-directory/

Thanks
Sheila Ruth

Hi Sheila,

This is how it works by default in wordpress and not on X theme. You may check this guide:

There’s also a plugin that might help: https://wordpress.org/plugins/advanced-excerpt/
Just note that any issue with integration and functionalities of the plugin should be directed to it’s developer.

Hope this helps.

That’s strange, because I first contacted support for the Pods plugin, and they said that it isn’t normal for the html to be stripped, and it might be something in the theme.

Can you tell me what filter I would need to override in the php, and what file I should copy to the child theme in order to override it?

Oh, and also, when I switch to the Twenty-Sixteen theme it works fine, so it’s definitely something in X.

Here is the archive page under X theme, and you can see the html stripped out:

Here’s the same archive page under Twenty-sixteen:

The Twenty Sixteen theme out of the box uses full post content and not excerpt. There’s full post content option in X too. Go to Appearance > Customize > Blog and under Content, enable Full Post Content on Index.

Thanks.

The problem is that this is not a true “excerpt” and I may have made an erroneous assumption when I thought that the issue was the excerpt. This is essentially a custom post type created with Pods and using their templating system to format what’s being displayed on the archive page. The template consists of several custom fields formatted with html tags around them. They think that the issue is the the_content filter, and asked me to check whether the theme is doing anything unusual with the the_content filter.

Hello There,

Thanks for updating in! We do not have any filters that change the content and the excerpts. X theme simply displays the excerpts in all of the archive pages. So in your case, you will need to display the full content in the archive pages so that your PODS single post will display. To resolve your issue, please do the following:

First: You will need to enable the “Full Post Content on Index” in the theme options, X > Launch > Options > Blog > Content. Selecting the “Enable Full Post Content on Index” option below will allow the entire contents of your posts to be shown on the post index pages for all stacks.

Second: Assuming that you have your child theme active and ready, please follow the following steps below:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/GLOBAL/_CONTENT.PHP
// -----------------------------------------------------------------------------
// Display of the_excerpt() or the_content() for various entries.
// =============================================================================

$stack                     = x_get_stack();
$is_full_post_content_blog = ( is_home() || is_archive() ) && x_get_option( 'x_blog_enable_full_post_content' ) == '1';

?>

<?php

if ( is_singular() || $is_full_post_content_blog ) :
  x_get_view( 'global', '_content', 'the-content' );
  if ( $stack == 'renew' ) :
    x_get_view( 'renew', '_content', 'post-footer' );
  endif;
else :
  x_get_view( 'global', '_content', 'the-excerpt' );
endif;

?>

3] Save the file named as _content.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/global/
You will need to create the folder names since this path does not exist yet in your child theme.

Hope this helps. Please let us know how it goes.

I don’t want to set the “Full Post Content on Index” globally for all content types, only for my custom type, so here’s what I ended up doing, for future reference in case anyone else is having this problem.

I copied the _content.php file from wp-content/themes/x/framework/views/global/ to my child theme wp-content/themes/x-child/framework/views/global/ and edited it as follows:

      <?php

// =============================================================================
// VIEWS/GLOBAL/_CONTENT.PHP
// -----------------------------------------------------------------------------
// Display of the_excerpt() or the_content() for various entries.
// =============================================================================

$stack                     = x_get_stack();
$is_full_post_content_blog = is_home() && x_get_option( 'x_blog_enable_full_post_content' ) == '1';

?>

<?php

if ( is_singular() || $is_full_post_content_blog || get_post_type()=='groups') :
  x_get_view( 'global', '_content', 'the-content' );
  if ( $stack == 'renew' ) :
    x_get_view( 'renew', '_content', 'post-footer' );
  endif;
else :
  x_get_view( 'global', '_content', 'the-excerpt' );
endif;

?>

Essentially, I added the " || get_post_type()=='groups" so that for my “groups” custom type, it would treat it the same as a singular page and run it through the_content() and not the_excerpt(). That worked and now my PODS archive page is displaying with the HTML as I defined in the Pods template.

Hello There,

We are just glad that you have figured it out a way to correct the said issue.
Thanks for letting us know!

Best Regards.

Thanks for this Sheila, it was very helpful. I stole your idea to give my category pages the full posts instead of excerpts. I modded that same line to read:
if ( is_singular() || $is_full_post_content_blog || is_category() ) :

Great work!
Thanks for sharing your solution.

Great! I’m glad it was helpful.