WordPress Codesnippets

woocommerce get category featured image


This code retrieves the thumbnail image associated with a category and displays it. It uses get_queried_object() to get the ID of the current category; then it uses get_term_meta() to retrieve the thumbnail’s ID associated with the category. The wp_get_attachment_url() function is then used to get the URL of the thumbnail image, and the image is displayed with an echo statement.

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 »