Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wordpress rest_no_route custom post type


/**
 * Register a genre post type, with REST API support
 *
 * Based on example at: https://codex.wordpress.org/Function_Reference/register_taxonomy
 */
add_action( 'init', 'my_book_taxonomy', 30 );
function my_book_taxonomy() {
 
  $labels = array(
    'name'              => _x( 'Genres', 'taxonomy general name' ),
    'singular_name'     => _x( 'Genre', 'taxonomy singular name' ),
    'search_items'      => __( 'Search Genres' ),
    'all_items'         => __( 'All Genres' ),
    'parent_item'       => __( 'Parent Genre' ),
    'parent_item_colon' => __( 'Parent Genre:' ),
    'edit_item'         => __( 'Edit Genre' ),
    'update_item'       => __( 'Update Genre' ),
    'add_new_item'      => __( 'Add New Genre' ),
    'new_item_name'     => __( 'New Genre Name' ),
    'menu_name'         => __( 'Genre' ),
  );
 
  $args = array(
    'hierarchical'          => true,
    'labels'                => $labels,
    'show_ui'               => true,
    'show_admin_column'     => true,
    'query_var'             => true,
    'rewrite'               => array( 'slug' => 'genre' ),
    'show_in_rest'          => true, 
    'rest_base'             => 'genre',
    'rest_controller_class' => 'WP_REST_Terms_Controller',
  );
 
  register_taxonomy( 'genre', array( 'book' ), $args );
 
}

Add these to enable rest support

   'show_in_rest'          => true, 
    'rest_base'             => 'genre',
    'rest_controller_class' => 'WP_REST_Terms_Controller',
Comment

wordpress rest_no_route custom post type

//remove show_in_rest from. argument then this will work

$args = array(
    'hierarchical'          => true,
    'labels'                => $labels,
    'show_ui'               => true,
    'show_admin_column'     => true,
    'query_var'             => true,
    'rewrite'               => array( 'slug' => 'genre' ),
    'show_in_rest'          => true,  //remove
    'rest_base'             => 'genre',// remove
    'rest_controller_class' => 'WP_REST_Terms_Controller',//remove
  );
 
  register_taxonomy( 'genre', array( 'book' ), $args );
Comment

PREVIOUS NEXT
Code Example
Php :: yii2 sendemail extension 
Php :: fallo al conectar al servidor ftp wordpress 
Php :: IP Authorization php code 
Php :: php ErrorException Undefined variable inside array_map 
Php :: php glob sort by unsigned int 
Php :: php max 
Php :: PHP OOP - Destructor 
Php :: laravel call controller method from another controller 
Php :: wp large medium large 
Php :: stripe php sdk constants 
Php :: php sentense case 
Php :: Skip model mutator 
Php :: laravel pagination get items array 
Php :: wc php get product id image gellery 
Php :: php take out 2 level array key value 
Php :: laravel validation if another record is not deleted / not null 
Php :: consumir soap php 
Php :: laravel OrderBy on Eloquent whereHas relationship 
Php :: php artisan make:widget 
Php :: Invalid datetime format: 1366 Incorrect string value 
Php :: laravel install 
Php :: toast in laravel 
Php :: view blob phpmyadmin 
Php :: Laravel Deploy in production 
Php :: Dynamic Carousel in Laravel not working displays only one image 
Php :: laravel redis sentinel 
Php :: Web servers supported by php 
Php :: How do I ge the version of wordpress? 
Php :: CONVERTIR TABLEAU EN CHAINE DE CARACTÈRE PHP 
Php :: php unique id length 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =