WordPress Codesnippets

woocommerce get product category image by id

				
					
				
			

This code retrieves the image of a product category given its ID and displays it if it is found. The product category ID is retrieved as an integer from the $_GET array. Then, the thumbnail ID is obtained from the term meta of the product category with the same ID. Finally, the image is retrieved from the attachment URL of the thumbnail ID and displayed if it is valid.

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 »