Posted By

novastream on 09/13/13


Tagged

page wordpress hook


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

FlashBuddy


Wordpress, page hook


 / Published in: PHP
 

URL: http://www.novastream.se

If you use a PHP code widget or want to change code based on the page your on.. Perhaps you want to change image based on what page your on...

  1. <?php
  2. $url = $_SERVER['REQUEST_URI'];
  3. $tokens = explode('/', $url);
  4. $part = $tokens[sizeof($tokens)-2];
  5.  
  6. if($part == "page-one") {
  7. echo '<img src="image1.jpg" />';
  8. }
  9.  
  10. elseif($part == "page-two") {
  11. echo '<img src="image2.jpg" />';
  12. }
  13.  
  14. else {
  15. //Nothing here aka error
  16. }
  17. ?>

Report this snippet  

You need to login to post a comment.