• Resolved kubiq

    (@kubiq)


    Hello,

    there are no terms in my CPT single post edit screen and I can see an error in the console trying to reach this URL:
    /wp-json/wp/v2/technology?per_page=100&orderby=name&order=asc&_fields=id%2Cname%2Cparent&_locale=user
    and that URL says:

    {
        code: "rest_invalid_param",
        message: "Invalid parameter(s): orderby",
        data: {
            status: 400,
            params: {
                orderby: "orderby is not one of author, date, id, include, modified, parent, relevance, slug, include_slugs, and title."
            },
            details: {
                orderby: {
                    code: "rest_not_in_enum",
                    message: "orderby is not one of author, date, id, include, modified, parent, relevance, slug, include_slugs, and title.",
                    data: null
                }
            }
        }
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    hi @kubiq Thanks for reporting this. Can you confirm that this happens in a default environment? Ie, no other plugins active and a basic theme (like twenty twenty four)?

    I’m asking because I don’t actually add any sort parameters and use the taxonomy’s rest_base as an endpoint which should be a simple string with no parameters, but I’ll try to dig into this a bit more when I can.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Actually it does look like I am responsible for adding an orderby param. But I cannot reproduce the error with my own attempt at a CPT. And name seems like it should be allowed in the enum. Are you perhaps filtering rest_{$this->taxonomy}_collection_params somewhere?

    Could you share your custom post type and custom tax registration code?

    Thread Starter kubiq

    (@kubiq)

    Hello,

    it’s generated with ACF PRO.

    Here is JSON: https://share.kubiq.sk/acf-export-2025-05-07.json

    or here is PHP version:

    add_action( 'init', function() {
        register_taxonomy( 'technology', array(
        0 => 'technology',
        1 => 'product',
    ), array(
        'labels' => array(
            'name' => 'Technologies',
            'singular_name' => 'Technology',
            'menu_name' => 'Technologies',
            'all_items' => 'All Technologies',
            'edit_item' => 'Edit Technology',
            'view_item' => 'View Technology',
            'update_item' => 'Update Technology',
            'add_new_item' => 'Add New Technology',
            'new_item_name' => 'New Technology Name',
            'parent_item' => 'Parent Technology',
            'parent_item_colon' => 'Parent Technology:',
            'search_items' => 'Search Technologies',
            'not_found' => 'No technologies found',
            'no_terms' => 'No technologies',
            'filter_by_item' => 'Filter by technology',
            'items_list_navigation' => 'Technologies list navigation',
            'items_list' => 'Technologies list',
            'back_to_items' => '← Go to technologies',
            'item_link' => 'Technology Link',
            'item_link_description' => 'A link to a technology',
        ),
        'public' => false,
        'hierarchical' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_nav_menus' => true,
        'show_in_rest' => true,
        'show_tagcloud' => false,
        'show_admin_column' => true,
        'rewrite' => array(
            'with_front' => false,
        ),
        'default_term' => array(
            'name' => 'Wireless',
        ),
        'sort' => true,
    ) );
    } );
    
    add_action( 'init', function() {
        register_post_type( 'technology', array(
        'labels' => array(
            'name' => 'Technologies',
            'singular_name' => 'Technology',
            'menu_name' => 'Technologies',
            'all_items' => 'All Technologies',
            'edit_item' => 'Edit Technology',
            'view_item' => 'View Technology',
            'view_items' => 'View Technologies',
            'add_new_item' => 'Add New Technology',
            'add_new' => 'Add New Technology',
            'new_item' => 'New Technology',
            'parent_item_colon' => 'Parent Technology:',
            'search_items' => 'Search Technologies',
            'not_found' => 'No technologies found',
            'not_found_in_trash' => 'No technologies found in Trash',
            'archives' => 'Technology Archives',
            'attributes' => 'Technology Attributes',
            'insert_into_item' => 'Insert into technology',
            'uploaded_to_this_item' => 'Uploaded to this technology',
            'filter_items_list' => 'Filter technologies list',
            'filter_by_date' => 'Filter technologies by date',
            'items_list_navigation' => 'Technologies list navigation',
            'items_list' => 'Technologies list',
            'item_published' => 'Technology published.',
            'item_published_privately' => 'Technology published privately.',
            'item_reverted_to_draft' => 'Technology reverted to draft.',
            'item_scheduled' => 'Technology scheduled.',
            'item_updated' => 'Technology updated.',
            'item_link' => 'Technology Link',
            'item_link_description' => 'A link to a technology.',
        ),
        'public' => true,
        'show_in_rest' => true,
        'menu_icon' => 'dashicons-admin-tools',
        'supports' => array(
            0 => 'title',
            1 => 'editor',
            2 => 'excerpt',
            3 => 'revisions',
            4 => 'thumbnail',
        ),
        'has_archive' => true,
        'rewrite' => array(
            'feeds' => false,
            'pages' => false,
        ),
        'delete_with_user' => false,
    ) );
    } );

    Yes, there are many other plugins, but I can not deactivate them and currently I have no time to copy this website to staging and test this, but maybe in the weekend…

    Plugin Author HelgaTheViking

    (@helgatheviking)

    hi, just wanted to let you know that I’m on vacation and unable to look at this for another couple of weeks.

    Check out the wp staging plugin for quick staging sites.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Hi @kubiq – I took another look at this and this endpoint /wp-json/wp/v2/technology is for fetching posts (or CPTs) and not what I am using to fetch taxonomy terms. I mixed it up since you have a tax and a CPT with the same name.

    I am able to reproduce this error with your above code snippet and RB4T disabled, which rules out any bugs with the plugin. Here’s a screenshot:

    https://imgur.com/a/31rQQCT

    I was able to resolve the issue by renaming the CPT slug to technologycpt so that the cpt and the tax don’t have the same slug. Why that works is beyond me.

    Thread Starter kubiq

    (@kubiq)

    ok, thank you for your time

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Wrong orderby parameter?’ is closed to new replies.