Wordpress single child category link


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

Mostrar un link a una subcategoría, dependiendo de la categoría superior. category_parent es igual al id de la categoría superior. Sirve sólo cuando el post tiene una categoría hija de la categoría superior.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. foreach((get_the_category()) as $category) {
  4. if($category->category_parent == 193):
  5. echo '<em>por <a href="/archives/category/'. $category->category_nicename.'">' . $category->cat_name . '</a></em>';
  6. endif;
  7. }
  8.  
  9. ?>

Report this snippet


Comments


You need to login to view comments.