WordPress Codesnippets

woocommerce get custom attribute value


This code allows a WordPress user to retrieve the value for the ‘_woocommerce_attribute_value’ post meta key for the current post. It does this by using the get_post_meta() function, passing in the ID of the current post and the meta key as parameters. The true parameter indicates that the function should return a single value.

Was this code snippet helpful?

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 »