• Resolved iceytina

    (@iceytina)


    I’m rather new at PHP. This is my first ever plugin to try to code, and it will be quite simple either way… and I only started coding it today so it’s extremely incomplete to say the least.

    I have 2 custom post type taxonomies so far, and plan to have several others: gender and breed. However, only Gender shows. And when I coded in breed, only Breed showed, but with the Gender settings.

    Am I missing a bracket or parenthesis or is something not coded right? Any insight would be appreciated. I can’t find what the problem is, but I’m sure since I’m such a noobie, that it’s something really obvious…

    Here’s my very incomplete code:

    class ADL_Cats_Listing_Post_Type {
    	public function __construct()
    	{
    		$this->register_post_type();
    		$this->taxonomies();
    	}
    
    	public function register_post_type()
    	{
    		$args = array(
    			'labels' => array(
    				'name' => 'Cat Listings',
    				'singular_name' => 'Cat Listing',
    				'add_new' => 'Add Cat Listing',
    				'add_new_item' => 'Add Cat Listing',
    				'edit_item' => 'Edit Cat Listing',
    				'new_item' => 'Add New Cat Listing',
    				'view_item' => 'View Cat Listings',
    				'search_items' => 'Search Cat Listings',
    				'not_found' => 'No Cat Listings Found',
    				'not_found_in_trash' => 'No Cat Listings found in the Trash'
    			),
    			'query_var' => 'cats',
    			'rewrite' => array(
    				'slug' => 'cats/',
    			),
    			'public' => true,
    			// 'menu_position' => 5,
    			'menu_icon' => admin_url() . 'images/media-button-image.gif',
    			'supports' => array(
    				'title',
    				'thumbnail',
    				'excerpt',
    			)
    		);
    		register_post_type('adl_catslistings', $args);
    	}
    
    	public function taxonomies()
    	{
    		$taxonomies = array();
    
    		$taxonomies['gender'] = array(
    			'query_var' => 'adl_gender',
    			'rewrite' => array(
    				'slug' => 'cats/gender/'
    			),
    			'labels' => array(
    				'name' => 'Gender',
    				'singular_name' => 'Gender',
    				'edit_item' => 'Edit Gender',
    				'update_item' => 'Update Gender',
    				'add_new_item' => 'Add Gender',
    				'new_item_name' => 'Gender',
    				'all_items' => 'All Genders',
    				'search_items' => 'Search Gender',
    				'popular_items' => 'Popular Genders',
    				'separate_items_with_comments' => 'Separate genders with comments',
    				'add_or_remove_items' => 'Add or remove Gender',
    				'choose_from_most_used' => 'Choose from most used genders'
    			)
    		);
    
    		$taxonomies['breeds'] = array(
    			'query_var' => 'adl_breeds',
    			'rewrite' => array(
    				'slug' => 'cats/breeds/'
    			),
    			'labels' => array(
    				'name' => 'Breeds',
    				'singular_name' => 'Breed',
    				'edit_item' => 'Edit Breed',
    				'update_item' => 'Update Breed',
    				'add_new_item' => 'Add Breed',
    				'new_item_name' => 'Breed',
    				'all_items' => 'All Breeds',
    				'search_items' => 'Search Breed',
    				'popular_items' => 'Popular Breeds',
    				'separate_items_with_comments' => 'Separate breeds with comments',
    				'add_or_remove_items' => 'Add or remove Breed',
    				'choose_from_most_used' => 'Choose from most used breeds'
    			)
    		);
    
    		$this->register_all_taxonomies($taxonomies);
    	}
    
    	public function register_all_taxonomies($taxonomies)
    	{
    		foreach($taxonomies as $name => $arr ) {
    			register_taxonomy('$name', array('adl_catslistings'), $arr);
    		}
    	}
    }
    
    add_action('init', function() {
    	new ADL_Cats_Listing_Post_Type();
    });
Viewing 1 replies (of 1 total)
  • Thread Starter iceytina

    (@iceytina)

    Lol yep I knew it.

    It was at the bottom.

    register_taxonomy('$name', array('adl_catslistings'), $arr);

    Was supposed to be

    register_taxonomy($name, array('adl_catslistings'), $arr);

    Solved.

Viewing 1 replies (of 1 total)
  • The topic ‘Coding shelter cat listing plugin– taxonomies not showing’ is closed to new replies.