Created
December 30, 2019 05:52
-
-
Save webprogramacion/58daa1d386f7aa03b80d6fe8706026fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filtro_personalizado_taxonomia() { | |
global $typenow; | |
// En el siguiente array añadimos la taxonomía que queremos mostrar. | |
// Hay que poner el slug de la taxonomía | |
$taxonomias = array('NOMBRE_TAXONOMIA'); | |
// Debemos seleccionar el tipo de post sobre el que se va a mostrar | |
if( $typenow == 'slug_del_tipo_de_post' ) | |
{ | |
foreach ($taxonomias as $slug_taxonomia) | |
{ | |
$taxonomia = get_taxonomy($slug_taxonomia); | |
$nombre_taxonomia = $taxonomia->labels->name; | |
$terms = get_terms($slug_taxonomia); | |
if(count($terms) > 0) | |
{ | |
echo "<select name='$slug_taxonomia' id='$slug_taxonomia' class='postform'>"; | |
echo "<option value=''>Mostrar todos $nombre_taxonomia</option>"; | |
foreach ($terms as $term) | |
{ | |
echo '<option value='. $term->slug, $_GET[$slug_taxonomia] == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>'; | |
} | |
echo "</select>"; | |
} | |
} | |
} | |
} | |
add_action( 'restrict_manage_posts', 'filtro_personalizado_taxonomia' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment