Closed nightillusions closed 3 years ago
Thanks for the report. Does this problem occur if you register the post type using the native register_post_type()
function from WordPress? Or does it only happen with Extended CPTs?
Hi,
with the native register_post_type()
it works. So it only happens with Extended CPTs:
function transport_zones_init() {
$labels = array(
'name' => __( 'Transportzonen', 'transport-zones' ),
'singular_name' => __( 'Transportzone', 'transport-zones' ),
'menu_name' => __( 'Transportzonen', 'transport-zones' ),
'name_admin_bar' => __( 'Transportzonen', 'transport-zones' ),
'add_new' => __( 'Neue erstellen', 'transport-zones' ),
'add_new_item' => __( 'Neue Transportzone erstellen', 'transport-zones' ),
'edit_item' => __( 'Bearbeiten', 'transport-zones' ),
'new_item' => __( 'Neue Transportzone', 'transport-zones' ),
'view_item' => __( 'Zeige Transportzone', 'transport-zones' ),
'search_items' => __( 'Suche nach Transportzone', 'transport-zones' ),
'not_found' => __( 'Keine Transportzone gefunden', 'transport-zones' ),
'not_found_in_trash' => __( 'Keine Transportzone im Papierkorb gefunden', 'transport-zones' ),
'all_items' => __( 'Alle Transportzonen', 'transport-zones' ),
'archives' => __( 'Transportzonenseite', 'transport-zones' ),
'featured_image' => __( 'Featured Image', 'transport-zones' ),
'set_featured_image' => __( 'Set featured image', 'transport-zones' ),
'remove_featured_image' => __( 'Remove featured image', 'transport-zones' ),
'use_featured_image' => __( 'Use as featured image', 'transport-zones' ),
'insert_into_item' => __( 'In Transportzone einfügen', 'transport-zones' ),
'uploaded_to_this_item' => __( 'Zu dieser Transportzone hochgeladen', 'transport-zones' ),
'views' => __( 'Filter Transportzonenliste', 'transport-zones' ),
'pagination' => __( 'Transportzonenlisten Navigation', 'transport-zones' ),
'list' => __( 'Transportzonenliste', 'transport-zones' ),
// Labels for hierarchical post types only.transport-zones
'parent_item' => __( 'Übergeordnete Transportzone', 'transport-zones' ),
'parent_item_colon' => __( 'Übergeordnete Transportzone:', 'transport-zones' ),
);
$args = array(
'labels' => $labels,
'description' => 'transport-zones custom post type.',
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'transport-zones' ),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 20,
'supports' => array( 'title' ),
'taxonomies' => array( 'category', 'post_tag' ),
'show_in_rest' => true
);
register_post_type( 'transport-zones', $args );
}
add_action( 'init', 'transport_zones_init' );
Okay, I close this Issue.
Finally I found the problem:
In WP 5.7 the rest_{$this->post_type}_query
hook changed in the order position, because of the new "taxquery".
My `rest{$this->post_type}_query` hook for ordering the rest response by custom field was the reason for all this. After some minor changes, everything works again.
Sorry ^^
Thanks for letting me know 👍
Okay, I close this Issue. Finally I found the problem: In WP 5.7 the
rest_{$this->post_type}_query
hook changed in the order position, because of the new "taxquery". My `rest{$this->post_type}_query` hook for ordering the rest response by custom field was the reason for all this. After some minor changes, everything works again.Sorry ^^
it still didn't get clear how did you solved this issue i am trying to query it through wp_query but i am not getting results for extended taxonomies using "tax_query"
As the title suggests, the custom post type "transport-zones" is no longer returning in the REST API endpoint "https://www.gabco.de/wp-json/wp/v2/transport-zones". Instead, the standard posts are returning under the this endpoint like from the endpoint "https://www.gabco.de/wp-json/wp/v2/posts". In contrast, the custom taxonomy "countries" works beautifully: https://www.gabco.de/wp-json/wp/v2/countries/
This has all worked for a year so far and recently it no longer works. I don't know if it's related to some update, anyway I didn't find any hints in the changelogs.
I would be very grateful for any help!
Code: