Title: Add php below navigation header
Last modified: February 17, 2024

---

# Add php below navigation header

 *  [ariextreme](https://wordpress.org/support/users/ariextreme/)
 * (@ariextreme)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/add-php-below-navigation-header/)
 * Hi, just a question since I want to upgrade from the Twenty Tweny One theme to
   Twenty Twenty Four. I want to add the PHP code for the banner advertisement as
   per currnet site (see link). Previously this was easy in the wordpress php file(
   e.g. single.php). Is there someone who can guide me how to do this in Twenty 
   Twenty Four? Many thanks for your help.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadd-php-below-navigation-header%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [jordesign](https://wordpress.org/support/users/jordesign/)
 * (@jordesign)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/add-php-below-navigation-header/#post-17434860)
 * Hey [@ariextreme](https://wordpress.org/support/users/ariextreme/),
 * > Hi, just a question since I want to upgrade from the Twenty Tweny One theme
   > to Twenty Twenty Four. I want to add the PHP code for the banner advertisement
   > as per currnet site (see link). Previously this was easy in the wordpress php
   > file (e.g. single.php). Is there someone who can guide me how to do this in
   > Twenty Twenty Four? Many thanks for your help.
 * Whilst Twenty Twenty Four won’t let us insert PHP directly into the template –
   there may be some other options.
 * Can you share the PHP code for the banner that you’d need?
 *  Thread Starter [ariextreme](https://wordpress.org/support/users/ariextreme/)
 * (@ariextreme)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/add-php-below-navigation-header/#post-17435509)
 * Hi Jordesign,
 * Thank you for you reply. I would prefer not to work with a additional plugin.
   Here is the code that works well but now needs to be inserted in twenty tweny
   four between the header and the content:
 *     ```wp-block-code
       // path van de banners
       $banner[1] = "https://kitesurfpro.nl/wp-content/uploads/2023/12/2023-2024-ventum-kiteboarding.gif";
       $banner[2] = "https://kitesurfpro.nl/wp-content/uploads/2024/02/naish-pivot-nvision.gif";
   
       // de url's waaraan het plaatje gekoppeld moet worden
       $url[1] = "https://ventumkiteboarding.com/product-category/sets/";
       $url[2] = "https://www.naish.com/products/pivot-nvision?utm_source=kitesurfpro&utm_medium=cpm&utm_campaign=pivotnvision";
   
       // voer alt tags in
       $alt[1] = "Ventum Kiteboarding";
       $alt[2] = "Naish Pivot Nvision 2024";
   
       // hoeveel banners zijn er?
       $banners = count($banner);
       $random = rand(1, $banners);
   
           echo "<div class=\"alignwide banner-center\"><p  class=\"banner-center\"><a href=\"" . $url[$random] . "\" target=\"_self\"> ";
           echo "<img src=\"" . $banner[$random] . "\" border=\"1\" style=\"border-color: #000000\" loading=\"lazy\" width=\"970\" height=\"250\" alt=\"" . $alt[$random] . "\" title=\"" . $alt[$random] . "\"></a></p></div>";
       ```
   
 *  [Felipe Velzani](https://wordpress.org/support/users/felipevelzani/)
 * (@felipevelzani)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/add-php-below-navigation-header/#post-17441351)
 * Hi there,
 * While reviewing your code, I see it is quite simple and the only thing that you
   wouldn’t natively be able to do it show the banner randomly, so my recommendation
   would be to go to the editor and edit the single page/post this way.
 * As an alternative (in case you want to keep adding with code), I wonder if using
   a shortcode could be an option for you? It is relatively simple to create the
   shortcode, then you can just use it to add the banner wherever you want.
 * You can see more here: [https://codex.wordpress.org/Shortcode_API](https://codex.wordpress.org/Shortcode_API)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add php below navigation header’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/twentytwentyfour/1.5/screenshot.
   png)
 * Twenty Twenty-Four
 * [Support Threads](https://wordpress.org/support/theme/twentytwentyfour/)
 * [Active Topics](https://wordpress.org/support/theme/twentytwentyfour/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/twentytwentyfour/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/twentytwentyfour/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [script](https://wordpress.org/support/topic-tag/script/)

 * 3 replies
 * 3 participants
 * Last reply from: [Felipe Velzani](https://wordpress.org/support/users/felipevelzani/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/add-php-below-navigation-header/#post-17441351)
 * Status: not resolved