I have been having a lot of issues lately while creating custom post types. As per a tutorial online I created an mu-plugins directory in my wp-content directory. I created a custom\_post\_types.php file which has the following code:
function *custom\_post\_types*(){
*register\_post\_type*(‘show’, array(
‘rewrite’ => array(‘slug’ => ‘shows’),
‘has\_archive’ => true,
‘show\_in\_rest’ => true,
‘supports’ => array(‘title’, ‘editor’, ‘excerpt’),
‘public’ => true,
‘menu\_icon’ => ‘dashicons-calendar’,
‘labels’ => array(
‘name’ => ‘Shows’,
‘singular\_name’ => ‘Show’,
‘add\_new\_item’ => ‘Add New Show’,
‘edit\_item’ => ‘Edit Show’,
)
));
}
*add\_action*(‘init’, ‘custom\_post\_types’);
Now whenever I create a new post from my wordpress dashboard, standard or custom, I get the following error:
Updating Failed. The response is not a valid JSON response.
However, once I place the same function into my functions.php file in my theme directory there is no issue. I am not using any plugins currently. Is there an issue with having this function in my functions.php file as opposed to its own which is being called from the mu-plugins directory?
[ad_2]