• I have a site that I’ve been running for a year or so, and am finally getting to customize it. I have this template tag ( <?php echo do_shortcode(“[pro_ad_display_adzone id=6349]”); ?> ) that I’m trying to add to my site as a “fly in ad” on the bottom center of all of the pages/posts/homepage on my site. Or I have the short code ([pro_ad_display_adzone id=”6349″ flyin=”1″] ) that supposedly inserts it as “fly in ad” to all pages, but I’m not sure if a shortcode can be applied on homepage.. If anyone can advise me on where I can insert this code, please let me know. Much appreciated experts! kcat

Viewing 1 replies (of 1 total)
  • Hello,

    You can, in almost all circumstances, add a shortcode to a home page. That said, if you want the ad to show up on all pages then adding shortcodes to each page is probably going to end up being quite tedious. Thus we have what some have termed “template tags”.

    Template tags are so named because they’re snippets of PHP code designed to be inserted into your theme templates rather than in the functions.php file or a plugin. For instance if you want a certain snippet to run on all single posts, then you’d copy/paste that snippet into the single.php file. Likewise for pages you’d use the page.php file. Both the single.php and page.php files are part of the WordPress Template Hierarchy.

    The nice thing about “template tags” is that because they’re PHP, you can put them pretty much anywhere including files that aren’t part of the Template Hierarchy. So if you want that code to run on all pages, then it might make sense to put it in something like the header.php file or the footer.php file. Obviously where you put it might influence how the resulting code renders on the screen so you’ll need to consider the best place to put your code. For fixed position ads, it might be that you can insert the code anywhere and be fine, but you’ll likely need to experiment.

    Some knowledge of PHP syntax is usually a good thing when messing around with theme files. For instance it’s good to know not to put the <?php and ?> tags inside an existing PHP code block and to only put your code snippet inside a function or in a conditional statement if you specifically want it there. There are innumerable resources for learning/understanding PHP online so I’ll not jump into any of that here.

    I hope this is helpful. Please let me know either way.

    Cheers.

Viewing 1 replies (of 1 total)

The topic ‘How to insert Template Tag’ is closed to new replies.