• I have a custom taxonomy, called “location”, everything works fine, I can use it for labeling “open job position”, but the problem occurs, when I try to access the archive or click on a taxonomy tag.

    I have:

    – reset the permalinks many times
    – double checked the query
    – double checked arguments
    – seen this: https://wordpress.stackexchange.com/questions/42788/custom-taxonomy-archive-no-posts-found && https://wordpress.stackexchange.com/questions/274293/custom-taxonomy-returns-no-posts

    Here is the code:

    
        if ( ! function_exists( 'custom_taxonomy_career' ) ) {
        
        	// Register Custom Taxonomy
        	function custom_taxonomy_career() {
        
        		$labels = array(
        			'name'                       => _x( 'Locations', 'Taxonomy General Name', 'foxconndrc' ),
        			'singular_name'              => _x( 'Location', 'Taxonomy Singular Name', 'foxconndrc' ),
        			'menu_name'                  => __( 'Locations', 'foxconndrc' ),
        			'all_items'                  => __( 'All Items', 'foxconndrc' ),
        			'parent_item'                => __( 'Parent Item', 'foxconndrc' ),
        			'parent_item_colon'          => __( 'Parent Item:', 'foxconndrc' ),
        			'new_item_name'              => __( 'New Item Name', 'foxconndrc' ),
        			'add_new_item'               => __( 'Add New Item', 'foxconndrc' ),
        			'edit_item'                  => __( 'Edit Item', 'foxconndrc' ),
        			'update_item'                => __( 'Update Item', 'foxconndrc' ),
        			'view_item'                  => __( 'View Item', 'foxconndrc' ),
        			'separate_items_with_commas' => __( 'Separate items with commas', 'foxconndrc' ),
        			'add_or_remove_items'        => __( 'Add or remove items', 'foxconndrc' ),
        			'choose_from_most_used'      => __( 'Choose from the most used', 'foxconndrc' ),
        			'popular_items'              => __( 'Popular Items', 'foxconndrc' ),
        			'search_items'               => __( 'Search Items', 'foxconndrc' ),
        			'not_found'                  => __( 'Not Found', 'foxconndrc' ),
        			'no_terms'                   => __( 'No items', 'foxconndrc' ),
        			'items_list'                 => __( 'Items list', 'foxconndrc' ),
        			'items_list_navigation'      => __( 'Items list navigation', 'foxconndrc' ),
        		);
        		$args = array(
        			'hierarchical'      => true,
        			'labels'            => $labels,
        			'show_ui'           => true,
        			'show_admin_column' => true,
        			'query_var'         => true,
        			'public'			=> true,
        			'exclude_from_search' => false,			
        			'rewrite'           => array( 'slug' => 'career_location' ),
        		);
        		register_taxonomy( 'career_location', array( 'career', 'post' ), $args );
        
        	}
        	add_action( 'init', 'custom_taxonomy_career', 0 );
        
        }

    Here is whole CPT with the code: https://pastebin.com/LqEkv0ZW

Viewing 2 replies - 1 through 2 (of 2 total)
  • @vyskoczilova you need to pass has_archive => true in arguments array. So your arguments will be:

    
    $args = array(
    			'hierarchical'      => true,
    			'labels'            => $labels,
    			'show_ui'           => true,
    			'show_admin_column' => true,
    			'query_var'         => true,
    			'has_archive'       => true, 
    			'rewrite'           => array( 'slug' => 'career_location' ),
    		);
    
    Pete

    (@perthmetro)

    It also helps to refresh your permalinks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom taxonomy archive – no posts found’ is closed to new replies.