In some situations, we’re using the Views plugin (affiliate link) to make it easier to create and output extremely custom information. For instance, in one case, we’re using it to set up entirely custom XML feeds that can be quickly and simply tweaked within the WordPress dashboard. While we fully recognize that this isn’t a supported use of the plugin, it is something that’s worked fairly well for us for the past 6 months or so.
However, in the most recent version of Views, they added some additional HTML wrapped around the output of all Views. I completely understand why they did what they did, and it allowed them to drastically improve some of the features they’ve had in the plugin for a while.
In our case, though, that HTML caused our custom feeds to stop working.
In order to correct the issue, I looked through the Views code a bit, and discovered that, although they’re not using an action to add the opening/closing HTML tags for the wrapper (so I can’t simply remove the action), they are registering and using a shortcode for that purpose. Therefore, in order to negate the extra HTML code, I needed to unregister the shortcodes (and, just to be safe, I re-registered them to return a blank string).
The shortcodes to be manipulated are the
wpv-layout-end shortcodes. The
wpv-layout-start shortcode outputs an opening
<div> tag with a bunch of classes and other meta attributes (and a hidden input tag with some other meta information); then the
wpv-layout-end shortcode simply outputs a closing
With the code below, I’m removing both shortcodes and then re-adding them to simply output an empty string.
It is important to keep in mind that you should only do this within the context where you need that extra HTML removed. Un-registering the shortcodes will stop them from outputting the wrapper anywhere on the page/document you’re rendering. More importantly, if you’re using a View inside of another View, that inner View most likely won’t include the wrapper, either. That could, potentially, cause some features within a View to stop working properly (for instance, this wrapper is used to implement pagination features). For us, we are only using this specifically within the function that outputs the custom feed.