We all know that there are plenty of plugins and hacks that allows execution of PHP in posts/pages and sidebars.
But how to execute PHP in category/tag description in WordPress?
I simply want to allow PHP codes in category/tag description so that I can show them in Category/Tags pages like <?php echo category_description(); ?>
.
By Default when
category_description()
gets called, it is filtered by code.But I suggest you to remove filter by adding them in functions.php of theme. Try something like this. I use it for html tags
The easiest way, without headaches, is to use a shortcode and send all variables as attributes, like:
And then parse all the
$atts
and content doing any PHP you want. To enable shortcodes in the category description, use:A test shortcode:
And the result using the sample description above: