0

I want my site to be able to automatically create and publish a new post once a woocommerce product is created and published. I want the post to have the same featured image of the published product as well as the same description.

On other-words products and posts should be generated simultaneously including same featured image and description.

1 Answer 1

1

WC products are posts themselves, so you could use:

add_action('publish_post', 'wpse_publish_post_with_product');

Within the new function, you'd have a check for post_type. If the post_type that was just published is a WC product, then grab the image and description from that post, and use wp_insert_post() to publish a Post with the same info.

Side note: I'm not sure what your goal is with publishing a Post in addition to a Product. Since both URLs will contain roughly the same information, you're likely to run into SEO problems with duplicate content. If you could elaborate on your goal, there might be a better, more SEO-friendly way to achieve it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.