WordPress.org

Forums

[resolved] embed HTML5 interactive animation in Category (3 posts)

  1. chuffORG2000
    Member
    Posted 1 year ago #

    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: http://technologyvcc.com/?p=47) using the below code, but in my "Room Signs" Category it just displays the code (see here: http://technologyvcc.com/?cat=4), 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:

    <?php
    
    	get_header();
    
    	if(have_posts()) :
    
    ?>
    
    		<div id="post">
    
    			<div class=" post-list-content">
    
    				<h1><?php echo single_cat_title('', false); ?></h1>
    
    			</div>
    
    		</div>
    <?php if (is_category('Room Signs')) : ?>
    <[iframe src="http://technologyvcc.com/GOOGLE_DESIGNER_TEST/GOOGLE-DESIGNER-TEST.html" 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; ?>
    <?php
    
    		get_template_part('content', 'postlist');
    
    	else :
    
    		get_template_part('content', 'none');
    
    	endif;
    
    	get_footer();
    
    ?>

    This is the code that works on Posts and Pages:

    [iframe src="http://technologyvcc.com/GOOGLE_DESIGNER_TEST/GOOGLE-DESIGNER-TEST.html" width="1200" height="600"] shortcode

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

    <?php
    
    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!

  2. bcworkz
    Member
    Posted 1 year ago #

    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="http://technologyvcc.com/GOOGLE_DESIGNER_TEST/GOOGLE-DESIGNER-TEST.html" width="1200" height="600"] shortcode'); ?>

    Be sure to coordinate or escape internal quotes.

  3. chuffORG2000
    Member
    Posted 1 year ago #

    Worked like a charm! Thanks so much bcworkz!

Topic Closed

This topic has been closed to new replies.

About this Topic