WordPress Codesnippets

add page to menu

				
					
				
			

The new page will have the title you specify for $page_title, and the menu item for the page will have the title you specify for $menu_title. You need to have the capability specified in $capability in order to see the new page, and the menu item for the page will have the slug you specify in $menu_slug. The $function parameter is a callback function that will run when the new page is loaded. You can also specify an icon to be used for the menu item with $icon_url, and you can specify the position of the new menu item with $position.

Was this code snippet helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »