Es werden nur benutzerdefinierte Beitragstypen einer bestimmten Kategorie angezeigt

Ich habe einige faqs auf meiner Website und möchte nur die faqs unter einer bestimmten Kategorie anzeigen. Die Kategorien umfassen worker , company , test .

Hier ist mein Code:

 $faq = new WP_Query(array( 'post_type'=>'faq', 'order' => 'DESC', 'category_name' => 'test', )); while($faq->have_posts()) : $faq->the_post(); 

Dies sollte mir alle Beiträge unter der Kategorie Test zeigen, tut es aber nicht. Ich habe auch cat => (id) ausprobiert und immer noch kein Ergebnis. Die Schleife ist immer leer.

Hier sind die Registrierungsfunktionen:

 function faq_post_type() { // these are the labels in the admin interface, edit them as you like $labels = array( 'name' => _x( 'FAQs', 'Post Type General Name', 'faq' ), 'singular_name' => _x( 'FAQ', 'Post Type Singular Name', 'faq' ), 'menu_name' => __( 'FAQ', 'faq' ), 'parent_item_colon' => __( 'Parent Item:', 'faq' ), 'all_items' => __( 'All Items', 'faq' ), 'view_item' => __( 'View Item', 'faq' ), 'add_new_item' => __( 'Add New FAQ Item', 'faq' ), 'add_new' => __( 'Add New', 'faq' ), 'edit_item' => __( 'Edit Item', 'faq' ), 'update_item' => __( 'Update Item', 'faq' ), 'search_items' => __( 'Search Item', 'faq' ), 'not_found' => __( 'Not found', 'faq' ), 'not_found_in_trash' => __( 'Not found in Trash', 'faq' ), ); $args = array( // use the labels above 'labels' => $labels, // we'll only need the title, the Visual editor and the excerpt fields for our post type 'supports' => array( 'title', 'editor', 'excerpt', ), // we're going to create this taxonomy in the next section, but we need to link our post type to it now 'taxonomies' => array( 'faq_tax' ), // make it public so we can see it in the admin panel and show it in the front-end 'public' => true, // show the menu item under the Pages item 'menu_position' => 20, // show archives, if you don't need the shortcode 'has_archive' => true, ); register_post_type( 'faq', $args ); } // hook into the 'init' action add_action( 'init', 'faq_post_type', 0 ); 

und Kategorie:

 function faq_post_category() { // again, labels for the admin panel $labels = array( 'name' => _x( 'FAQ Categories', 'Taxonomy General Name', 'faq' ), 'singular_name' => _x( 'FAQ Category', 'Taxonomy Singular Name', 'faq' ), 'menu_name' => __( 'FAQ Categories', 'faq' ), 'all_items' => __( 'All FAQ Cats', 'faq' ), 'parent_item' => __( 'Parent FAQ Cat', 'faq' ), 'parent_item_colon' => __( 'Parent FAQ Cat:', 'faq' ), 'new_item_name' => __( 'New FAQ Cat', 'faq' ), 'add_new_item' => __( 'Add New FAQ Cat', 'faq' ), 'edit_item' => __( 'Edit FAQ Cat', 'faq' ), 'update_item' => __( 'Update FAQ Cat', 'faq' ), 'separate_items_with_commas' => __( 'Separate items with commas', 'faq' ), 'search_items' => __( 'Search Items', 'faq' ), 'add_or_remove_items' => __( 'Add or remove items', 'faq' ), 'choose_from_most_used' => __( 'Choose from the most used items', 'faq' ), 'not_found' => __( 'Not Found', 'faq' ), ); $args = array( // use the labels above 'labels' => $labels, // taxonomy should be hierarchial so we can display it like a category section 'hierarchical' => true, // again, make the taxonomy public (like the post type) 'public' => true, ); // the contents of the array below specifies which post types should the taxonomy be linked to register_taxonomy( 'faq_category', array( 'faq' ), $args ); } // hook into the 'init' action add_action( 'init', 'faq_post_category', 0 ); 

Solutions Collecting From Web of "Es werden nur benutzerdefinierte Beitragstypen einer bestimmten Kategorie angezeigt"