Support » Plugins » Hacks » embed HTML5 interactive animation in Category

  • Resolved chuffORG2000


    Hello, I’ve done a ton of searching on this and no luck, plus I’m much more of a graphic designer than web designer, so please forgive my noob-ish understanding of code. I can get it to work in Pages and Posts (see here: using the below code, but in my “Room Signs” Category it just displays the code (see here:, which I entered into the categories Description field. I’m doing all this in a child theme, and have created a category.php for it with this code:

    	if(have_posts()) :
    		<div id="post">
    			<div class=" post-list-content">
    				<h1><?php echo single_cat_title('', false); ?></h1>
    <?php if (is_category('Room Signs')) : ?>
    <[iframe src="" width="1200" height="600"] shortcode>
    <p>This is the text to describe Room Signs</p>
    <?php elseif (is_category('Kiosks')) : ?>
    <p>This is the text to describe Kiosks</p>
    <?php else : ?>
    <p>This is some generic text to describe all other category pages,
    I could be left blank</p>
    <?php endif; ?>
    		get_template_part('content', 'postlist');
    	else :
    		get_template_part('content', 'none');

    This is the code that works on Posts and Pages:

    [iframe src="" width="1200" height="600"] shortcode

    I’ve also added the below to a new functions.php in my child theme:

    add_shortcode('iframe', 'ag_iframe');
    function add_iframe($initArray) {
    $initArray['extended_valid_elements'] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]";
    return $initArray;
    add_filter('tiny_mce_before_init', 'add_iframe');

    Any help is greatly appreciated, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    Shortcodes are not expanded on random template content, only on post (and on other post types, like page ) content. To get shortcodes expanded on templates, call do_shortcode() on the template, passing the shortcode text string as the parameter, like so:
    <?php echo do_shortcode('[iframe src="" width="1200" height="600"] shortcode'); ?>

    Be sure to coordinate or escape internal quotes.

    Worked like a charm! Thanks so much bcworkz!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘embed HTML5 interactive animation in Category’ is closed to new replies.