Single post depending on the category


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



Copy this code and paste it in your HTML
  1. <?php
  2. if (in_category(1)) { // Si el post pertenece a la cat 1, redirigir a single-1.php
  3. include(TEMPLATEPATH . '/single1.php');
  4. } elseif (in_category(2)) { // Si el post pertenece a la cat 2, redirigir a single-2.php
  5. include(TEMPLATEPATH . '/single2.php');
  6. } else { // Si el post pertenece a la cat 3, redirigir a single-3.php
  7. include(TEMPLATEPATH . '/single3.php');
  8. } ?>

URL: http://www.todowp.org/mostrando-distintos-single-php-paginas-de-articulo-segun-la-categoria/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.