Access Request URI in WordPress for template reuse


/ Published in: PHP
Save to your folder(s)

Easy way to access request URI to WP in order to not repeat whole templates for minor changes


Copy this code and paste it in your HTML
  1. <?php
  2. switch ($wp->request) {
  3. case 'directory':
  4. get_template_part('content', 'directory');
  5. break;
  6. case 'history':
  7. get_template_part('content', 'history');
  8. break;
  9. default: get_template_part('content', 'default');
  10. };
  11. ?>

URL: http://kovshenin.com/2012/current-url-in-wordpress/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.