WordPress Codesnippets

add archive page to menu

				
					
				
			

New Book’ ),
‘view_item’ => __( ‘View Book’ ),
‘search_items’ => __( ‘Search Books’ ),
‘not_found’ => __( ‘No books found’ ),
‘not_found_in_trash’ => __( ‘No books found in Trash’ ),
‘parent_item_colon’ => ”
);
$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘query_var’ => true,
‘rewrite’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘menu_position’ => null,
‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ )
);
register_post_type( ‘book’, $args );

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 »