Shiva Poudel :: WordPress Developer

WooCommerce – Prevent order view link being triggered on row click — February 3, 2018
WordPress – Enable Dashicons in Frontend — January 31, 2018
WordPress – Disable “Add New” on Custom Post Type — January 18, 2018

WordPress – Disable “Add New” on Custom Post Type

There is a meta capability create_posts that is not documented but is used by WordPress to check before inserting the various “Add New” buttons and links. In your custom post type declaration, add capabilities (not to be confused with cap) and then set it to do_not_allow as in the below snippet. Additionally, to map meta capabilities for custom post types we can use map_meta_cap hook as it’s explain here:

In the below snippet we will be using “feedback” custom post type as an example.

WooCommerce – Enable REST API permissions check — January 17, 2018
WooCommerce – Automatically add product to cart on visit — January 16, 2018
WooCommerce – Allow rendering of checkout and account pages in iframes — January 15, 2018
WP REST API – Modify API base URL prefix. — January 12, 2018

WP REST API – Modify API base URL prefix.

The new URL for the REST API endpoints contain the prefix as well as a namespace like this:

If you don’t like the default base prefix and want to change it from wp-json to something more beautiful, the code snippet will help you to change the base prefix from wp-json to api.

As soon as you are done adding the above snippet, you have to flush rewrite rules by resaving permalinks from Settings > Permalinks to access all the data from your new api like this:

Want to learn about WP REST API? You can read the handbook here.