Wsparcie » Zaawansowane » Wiele taxonomy w jednym wpisie

  • zagir

    (@zagir)


    Witam chcę aby w jednym wpisie były dwie taxonomie.

    Zainstalowałem : Types Plugin – Custom Post Types, Taxonomies and Custom Fields
    Dodałem taxonomy: kategorie_tutoriali – ma wyświetlać kategorię
    i taxonomy: poziom – ma wyświetlać poziom trudności

    Chcę aby oba typy kategorii były wyświetlane we wpisie
    pierwszą wywołałem
    plik functions.php

    // get taxonomies terms links
    function custom_taxonomies_kategorie_tutoriali() {
    	global $post, $post_id;
    	// get post by post id
    	$post = &get_post($post->ID);
    	// get post type by post
    	$post_type = $post->post_type;
    	// get post type taxonomies
    	$taxonomies = get_object_taxonomies($post_type);
    	foreach ($taxonomies as $taxonomy) {
    		// get the terms related to post
    		$terms = get_the_terms( $post->ID, $taxonomy );
    		if ( !empty( $terms ) ) {
    			$out = array();
    			foreach ( $terms as $term )
    				$out[] = '<a href="' .get_term_link($term->slug, $taxonomy) .'">'.$term->name.'</a>';
    			$return = join( ', ', $out );
    		}
    	}
    	return $return;
    }

    contetnt.php
    <?php echo custom_taxonomies_kategorie_tutoriali(); ?>

    Ale gdy w analogiczny sposób tworzę funkcję drugą to mi zamienia i w miejscu gdzie powinna wyświetlić się kategoria wyświetla się poziom

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • Temat ‘Wiele taxonomy w jednym wpisie’ jest zamknięty na nowe odpowiedzi.