• Hi All,

    I am creating a responsive web site and would like to get adverts to
    match the device.

    I am using WP Mobile Detect by Jesse Friedman and it works perfectly on pages.

    I would like to use a global advert in header.php

    I cannot get the shortcodes to work in header.php

    I have tried adding functions, do shortcode etc but ma obviously missing something. The shortcodes I am using are [notphone][/notphone] and [phone][/phone]

    Any tips, hints or directions would be greatly appreciated.

    Thanks

    D
    <?php echo do_shortcode(“[notphone]”); ?>
    <div align=center>
    google advert code</div>
    <?php echo do_shortcode(“[/notphone]”); ?>

    <?php echo do_shortcode(“[phone]”); ?>
    <div align=center>
    google advert code</div>
    <?php echo do_shortcode(“[/phone]”); ?>

Viewing 1 replies (of 1 total)
  • I might be too late, but you have to use functions in php code, not shortcodes. Something like this:

    <?php if (function_exists ('wpmd_is_phone') && function_exists ('wpmd_is_notphone')) : ?>
    	<?php if (wpmd_is_notphone()) : ?>
    		<div align=center>
    		google advert code</div>
    	<?php endif; ?>
    	<?php if (wpmd_is_phone()) : ?>
    		<div align=center>
    		google advert code</div>
    	<?php endif; ?>
    <?php endif; ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Adding shortcodes to header.php’ is closed to new replies.