WordPress Codesnippets

add rewrite rule

				
					
				
			

This code is a rewrite rule that tells WordPress to take any URL that matches the pattern and redirect it to the specified URL. The pattern is made up of three capture groups, each of which will be captured and stored in the $matches array. The first capture group will be stored in $matches[1], the second in $matches[2], and the third in $matches[3]. The destination URL uses the $matches array to insert the captured values into the pagename, subpagename, and subsubpagename query parameters.

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 »