I have been trying for several days to create a custom post type with categories. While this works for me, I can easily add content and assign categories to it. My code is below.
What I donβt understand, and it doesnβt seem to work, creates an archive page to display category messages. For example: My message type is called Ads . My category is called Photographers .
Is it possible for the page to dynamically determine which category you are in and display all user messages related to this category?
function my_custom_post_advert() { $labels = array( 'name' => _x( 'Adverts', 'post type general name' ), 'singular_name' => _x( 'Advert', 'post type singular name' ), 'add_new' => _x( 'Add New', 'advert' ), 'add_new_item' => __( 'Add New Advert' ), 'edit_item' => __( 'Edit Advert' ), 'new_item' => __( 'New Advert' ), 'all_items' => __( 'All Adverts' ), 'view_item' => __( 'View Advert' ), 'search_items' => __( 'Search Adverts' ), 'not_found' => __( 'No adverts found' ), 'not_found_in_trash' => __( 'No adverts found in the Trash' ), 'parent_item_colon' => '', 'menu_name' => 'Adverts' ); $args = array( 'labels' => $labels, 'description' => 'Holds our adverts and advert specific data', 'public' => true, 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'category' ), 'has_archive' => true, ); register_post_type( 'advert', $args ); } add_action( 'init', 'my_custom_post_advert' ); function my_taxonomies_advert() { $labels = array( 'name' => _x( 'Advert Categories', 'taxonomy general name' ), 'singular_name' => _x( 'Advert Category', 'taxonomy singular name' ), 'search_items' => __( 'Search Advert Categories' ), 'all_items' => __( 'All Advert Categories' ), 'parent_item' => __( 'Parent Advert Category' ), 'parent_item_colon' => __( 'Parent Advert Category:' ), 'edit_item' => __( 'Edit Advert Category' ), 'update_item' => __( 'Update Advert Category' ), 'add_new_item' => __( 'Add New Advert Category' ), 'new_item_name' => __( 'New Advert Category' ), 'menu_name' => __( 'Advert Categories' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, ); register_taxonomy( 'advert_category', 'advert', $args ); } add_action( 'init', 'my_taxonomies_advert', 0 );