Return to Snippet

Revision: 33897
at October 14, 2010 22:33 by jhonqwerty


Updated Code
<?php

foreach((get_the_category()) as $category) {
		if($category->category_parent == 193):
                echo '<em>por <a href="/archives/category/'. $category->category_nicename.'">' . $category->cat_name . '</a></em>';
		endif;
		}
							
?>

Revision: 33896
at October 14, 2010 22:31 by jhonqwerty


Initial Code
<?php
//Mostrar un link a una subcategoría, dependiendo de la categoría superior. category_parent es igual al id de la categoría superior.

foreach((get_the_category()) as $category) {
							if($category->category_parent == 193):
							echo '<em>por <a href="/archives/category/'. $category->category_nicename.'">' . $category->cat_name . '</a></em>';
							endif;
							}
							
?>

Initial URL


Initial Description
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.

Initial Title
Wordpress single child category link

Initial Tags
php, wordpress, category

Initial Language
PHP