Custom Post Type
-
Hi,
First I would like to apologies if I made a thread in wrong forum. I got problem based my custom post type and plugin. I have setup my custom post type called Audio and in this custom post type got Audio, Add New Audio and Audio Genres.
Audio[Custom Post Type]
– Audio
– Add New Audio
– Audio GenresThe problem is, I’m using an autopost plugin and the plugin just appear my WordPress Categories not my Audio Genres. I’ve looked up my database on wp_terms, there is 2 categories called Acoustics. And the ID was 7 and 64. 7 come from WordPress Categories and 64 come from Audio Genres that I set in my Custom Post Type. So, how can I let the plugin show up my Audio Genres categories.
This is the source code from the plugin.
// categories $source_data->categories = array(); $cats_array = $this->WPDB->get_results(sprintf("SELECT <code>category</code> FROM <code>%s</code> WHERE <code>source</code> = %d", $this->tables['categories'], $source_id)); if (is_array($cats_array)) { while ($cat = array_shift($cats_array)) $source_data->categories[] = $cat->category; }
And this is the custom post type source code for your reference.
<?php // REGISTER AUDIO POST TYPE add_action('init', 'posttype_audio'); function posttype_audio() { $labels = array( 'name' => __('Audio', 'audio_mtlabs'), 'singular_name' => __('Album', 'audio_mtlabs'), 'add_new' => __('Add Album', 'audio_mtlabs'), 'add_new_item' => __('Add New Album','audio_mtlabs'), 'edit_item' => __('Edit Album','audio_mtlabs'), 'new_item' => __('New Album','audio_mtlabs'), 'view_item' => __('View Details','audio_mtlabs'), 'search_items' => __('Search Audio','audio_mtlabs'), 'not_found' => __('No Audio was found with that criteria','audio_mtlabs'), 'not_found_in_trash' => __('No Audio found in the Trash with that criteria','audio_mtlabs'), 'view' => __('View Album', 'audio_mtlabs') ); $imagepath = get_stylesheet_directory_uri() . '/images/posttypeimg/'; $args = array( 'labels' => $labels, 'description' => 'This is the holding location for all Albums', 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_ui' => true, 'rewrite' => true, 'hierarchical' => true, 'menu_position' => 5, 'menu_icon' => $imagepath . '/aud.png', 'supports' => array('thumbnail','title','comments','revisions') ); $labels = array( 'name' => _x( 'Audio Genres', 'taxonomy general name' ), 'singular_name' => _x( 'Audio Genre', 'taxonomy singular name' ), 'search_items' => __( 'Search Audio Genres' ), 'all_items' => __( 'All Audio Genres' ), 'parent_item' => __( 'Parent Audio Genre' ), 'parent_item_colon' => __( 'Parent Audio Genre:' ), 'edit_item' => __( 'Edit Audio Genre' ), 'update_item' => __( 'Update Audio Genre' ), 'add_new_item' => __( 'Add New Audio Genre' ), 'new_item_name' => __( 'New Audio Genre Name' ), ); register_taxonomy( 'audio_genre', array( 'audio' ), array( 'hierarchical' => true, 'labels' => $labels, /* NOTICE: Here is where the $labels variable is used */ 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'audio_genre' ), )); register_post_type('audio',$args); } ?>
- The topic ‘Custom Post Type’ is closed to new replies.