Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #245452

    I use this code for portfolio tag taxonomy:

    // registration code for portfoliotags taxonomy
    		function register_portfoliotags_tax() {
    			$labels = array(
    				'name' 			=> _x( 'Portfolio Tags', 'taxonomy general name' ),
    				'singular_name' 	=> _x( 'Portfolio Tag', 'taxonomy singular name' ),
    				'add_new' 		=> _x( 'Add New Portfolio Tag', 'Portfolio Tag'),
    				'add_new_item' 		=> __( 'Add New Portfolio Tag' ),
    				'edit_item' 		=> __( 'Edit Portfolio Tag' ),
    				'new_item' 		=> __( 'New Portfolio Tag' ),
    				'view_item' 		=> __( 'View Portfolio Tag' ),
    				'search_items' 		=> __( 'Search Portfolio Tags' ),
    				'not_found' 		=> __( 'No Portfolio Tag found' ),
    				'not_found_in_trash' 	=> __( 'No Portfolio Tag found in Trash' ),
    			);
    	
    			$args = array(
    				'labels' 		=> $labels,
    				'singular_label' 	=> __('Portfolio Tag'),
    				'public' 		=> true,
    				'show_ui' 		=> true,
    				'hierarchical' 		=> false,
    				'show_tagcloud' 	=> true,
    				'show_in_nav_menus' 	=> true,
    				'rewrite' 		=> array('slug' => 'portfolio-tag', 'with_front' => false ),
    			 );
    
    			register_taxonomy('portfoliotags', array('portfolio'), $args);
    		}
    		add_action('init', 'register_portfoliotags_tax');

    And this code to display the terms in loop-portfolio-single.php:
    echo get_the_term_list( $post->ID, 'portfoliotags', 'Tags: ', ' ', '' );

    When I click a term the page is refreshing, stays on the same link. Should go to the archive page. I used the same code for other themes and it works, but Eunoia use a different templates structure. What else should I do to make it work?

    Thanks!

    #246390

    Hey artofchris!

    Maybe you must add the custom post type to the archive query – see: http://wordpress.org/support/topic/custom-post-type-tagscategories-archive-page – insert the code into the eunoia/functions.php file.

    
    
    /*
    show tag archive page for post type - without this code you'll get 404 errors: http://wordpress.org/support/topic/custom-post-type-tagscategories-archive-page
    */
    if(!function_exists('avia_fix_tag_archive_page'))
    {
    	function avia_fix_tag_archive_page($query)
    	{
    	    $post_types = get_post_types();
    
    	    if ( is_category() || is_tag())
    	    {
    			if(!is_admin() && $query->is_main_query() )
    	        {
    		        $post_type = get_query_var(get_post_type());
    
    		        if ($post_type) {
    		            $post_type = $post_type;
    		        } else {
    		            $post_type = $post_types;
    		        }
    		        $query->set('post_type', $post_type);
    			}
    	    }
    
    	    return $query;
    	}
    	add_filter('pre_get_posts', 'avia_fix_tag_archive_page');
    }
    

    Cheers!
    Peter

    #246768

    The new tag is for portfolio so I need the portfolio archive layout. I end it up using a copy of the taxonomy-portfolio_entries.php with the proper modifications for “portfoliotags” taxonomy.

    Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Adding "Tag" taxonomy to Portfolio. "Archive Page" missing.’ is closed to new replies.