Title: Adding shortcodes to header.php
Last modified: August 22, 2016

---

# Adding shortcodes to header.php

 *  [webism](https://wordpress.org/support/users/webism/)
 * (@webism)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-shortcodes-to-headerphp/)
 * 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)

 *  [grief-of-these-days](https://wordpress.org/support/users/grief-of-these-days/)
 * (@grief-of-these-days)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-shortcodes-to-headerphp/#post-5803071)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [grief-of-these-days](https://wordpress.org/support/users/grief-of-these-days/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/adding-shortcodes-to-headerphp/#post-5803071)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
