<strong>What do i want to acheive?</strong><br>
- i want to create a post for my custom post type with the wordpress rest api<br>
<br>
<strong>What Api route is having problems?</strong><br>
- <a href="http://localhost/proftaak/wp-json/wp/v2/mycustomposttype" rel="nofollow noreferrer">http://localhost/proftaak/wp-json/wp/v2/mycustomposttype</a><br>
<br>
<strong>What http method are you using?</strong><br>
- <strong>POST</strong> method (post = not working, get = working)<br>
<br>
<strong>What Local apache server are you using?</strong><br>
- I'm using xampp as local apache + mysql server.<br>
<br>
<strong>What have i done?</strong><br>
- I created a new custom post type. see here:
<pre class="lang-php prettyprint-override">
i've set my custom post type to show_in_rest to true because i want to use it.
But if i do a post in postman to the url i get this:
<a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a><br>
i've researched a lot but can't find a solution.
any one an idea?
- i want to create a post for my custom post type with the wordpress rest api<br>
<br>
<strong>What Api route is having problems?</strong><br>
- <a href="http://localhost/proftaak/wp-json/wp/v2/mycustomposttype" rel="nofollow noreferrer">http://localhost/proftaak/wp-json/wp/v2/mycustomposttype</a><br>
<br>
<strong>What http method are you using?</strong><br>
- <strong>POST</strong> method (post = not working, get = working)<br>
<br>
<strong>What Local apache server are you using?</strong><br>
- I'm using xampp as local apache + mysql server.<br>
<br>
<strong>What have i done?</strong><br>
- I created a new custom post type. see here:
<pre class="lang-php prettyprint-override">
Code:
add_action('init', 'create_custom_post_types');
add_action('admin_menu', 'remove_default_post_types');
function create_custom_post_types()
{
// Apparaten (requests)
register_post_type('apparaten', [
'public' => true,
'show_in_rest' => true,
'label' => 'Apparaten',
'menu_icon' => 'dashicons-smartphone',
'capabilities' => array(
'create_posts' => false
),
'labels' => [
'singular_name' => 'Apparaat'
],
]);
}
function remove_default_post_types()
{
remove_menu_page( 'edit.php' );
remove_menu_page( 'edit-comments.php' );
}
i've set my custom post type to show_in_rest to true because i want to use it.
But if i do a post in postman to the url i get this:
<a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a><br>
i've researched a lot but can't find a solution.
any one an idea?