Some front end category pages don’t render if they contain a shortcode
-
I activated this free plugin and all appeared to be working well, I used the tinyMCE editor to add an image to a category page and it displayed perfectly. It was only some time later that I noticed some category pages wouldn’t render. Debugging the issue I found that the line
add_filter('term_description', 'do_shortcode');
in this plugin’s only file was causing the problem. If I commented out that line, the pages rendered properly.I suspected that the problem was an incompatibility with another plugin I was using called “Insert PHP Code Snippet”, it was already allowing me to use shortcodes in the category description. The category pages failing to render were pages where the description contained shortcodes. However, before debugging that route further, it occurred to me that this admin plugin shouldn’t really be doing anything when the front-end pages are being rendered. I added the following code at the top of the plugin file and that appears to solve the issue:
if( !is_admin() ) { return; }
I can live with making this small change to keep my site working. Obviously, this is the free version of the plugin, but it would be good to have a permanent solution whenever there is the another update.
- The topic ‘Some front end category pages don’t render if they contain a shortcode’ is closed to new replies.