• Given the following taxonomy and the code required to echo the results:

    <?php 
    
    	add_action( 'init', 'create_muscle_taxonomies', 0 );
    	function create_muscle_taxonomies()
    	{
    	  $labels = array(
    		'name' => __( 'Muscoli o gruppi muscolari', 'taxonomy general name' ),
    		'singular_name' => __( 'Muscolo o gruppo muscolare', 'taxonomy singular name' )
    	  ); 
    
    	  register_taxonomy('muscoli', 'post', array(
    		'hierarchical' => false,
    		'labels' => $labels,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => array( 'slug' => 'muscoli' ),
    	  ));
    	}
    
    ?>
    <?php
    
    	echo '<ul>';
    
    	$terms_of_post = get_the_term_list( $post->ID, 'muscoli', '<li>','<li>', '</li>', '' );
    	echo $terms_of_post;
    
    	echo '</ul>';
    
    ?>

    I can’t make it work properly: either it works on the admin side and doesn’t on the frontend, or viceversa.
    If I use this code:

    register_taxonomy('muscoli', 'post', array

    a new label appears inside the “Posts” menu, but I get no results on the frontend of the site if I try to echo em with the code I’ve pasted above.
    On the other hand, if I don’t specify ‘post’ as $object_type, as it follows:

    register_taxonomy('muscoli', '', array

    I can see the results echoed on the frontend of the site, but obviously the tag disappears from the admin side.

    I don’t understand what am I missing, anyone can help me?

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can't get taxonomy to work properly (frontend/admin issues)’ is closed to new replies.