Jetpack Publicize with WooCommerce Products
add_action('init', 'kraft_woo_publicize'); function kraft_woo_publicize() { add_post_type_support( 'product', 'publicize' ); }
This code snippet, for your theme’s functions.php or in a core functionality plugin adds Jetpack’s Publicize feature to WooCommerce products. This would allow you to auto-post to Facebook, Twitter, Google+, etc when you post a new WooCommerce product to your site.
UPDATE: WooCommerce now includes Publicize support by default out of the box as of version 2.3.0. If you want to disable this feature, use the following code:
add_action('init', 'kraft_woo_publicize_remove'); function kraft_woo_publicize_remove() { remove_post_type_support( 'product', 'publicize' ); }
35 Replies to “Jetpack Publicize with WooCommerce Products”
Leave a Reply
Thanks…your snippet saves me hours of digging 🙂
Happy to have helped!
Is it possible to edit which parts of a product are auto posted? Where are the posts placed together?
I’d need to check into how Woo works a bit more. Generally, Twitter will use the message in the Publish metabox. Facebook will use the manual excerpt first and default to the auto-generated excerpt if none present.
ahh sweet.. what a wicked little snippet..
thanks so much..
Re the excerpt.. if using “yoast seo for woo commerce..”
There is a panel to specify/create custom content for sharing on social media. so targeting is much easier.. Its an amazing plug also .. 🙂
hello, i tried the code above but it doesn’t work. i use wootheme mystile and have jetpack & woocommerce plugin installed.
Can you send a note to http://jetpack.me/contact-support/ ? Thanks!
Thanks! In case anyone else is nervous about whether to close of the PHP with a ?>, mine worked fine without.
Correct, the closing tag isn’t needed. In WordPress development, it is actually preferred not to having a closing tag per the WordPress Coding Standards.
Yup. But the functions.php file for my theme closed the tag, and I was nervous about it. So there you go.
Thank you very much, Brandon! Very nice tutorial!
my site crashes if posted to either functions or custom_functions
Don’t include the opening <?php if you’re adding this to an existing file.
doesn’t post anything.. shows options in post writer but never actually posts
A quick test confirmed it works for me on latest Jetpack/WordPress/Woo. You can send a note to Jetpack Support at http://jetpack.me/contact-support/
thanks Brandon.. note submitted
I want to share previous posts published before i added this code, but it lets mme to share only new posts.Any idea?
Sometimes, you can cycle the post status (e.g. Publish->Draft (save it as such)->Publish (re-save)) and it’ll go out.
Generally, Publicize aims for new posts so hitting older ones is a bit out of scope.
Thank you for answering, I have found a piece of code in the internet to tackles this issue.
Hi Fuad, could you tell what kind of solution you find, I am still looking and was not lucky to find something yet…
.. first time functions.php user, immediate success. only two times blank screen,ehh. you’ve made me to puzzle it out, many thanks and snippet is magic, can’t wait to try it ..
You’re just great, great snippet!
Sweet snippet! Thanks for sharing! You’ve saved me dude!
Thanks a lot man 🙂 realy helpede
Hi is there a way to grab updated products? And re-post them to twitter/facebook etc?
Not as it stands now. This issue will need to be resolved first before something like this is possible.
doesn’t post anything.. shows options in post writer but never actually posts
It still works for me. It may be an issue with your site’s connection to WordPress.com.
Thanks for Sharing! It helps me too much.
Hi there,
Great post, and thanks for updating the info.
I’m encountering this when posting new woocommerce products. The Facebook page and G+ do get updated with a photo post, however the Twitter, Tumblr simply get a text post without any images.
Does anybody know of a work around for that?
Could you send a note to https://jetpack.me/contact-support/ with the URLs of the posts that didn’t have an image. With Twitter, it relies on the open graph tags on the site so it’s possible that those pages don’t have OG image tags defined.
This was very helpful! Thank you!
Now for a bonus question: How about the option to use the code on https://jetpack.me/2013/10/15/ever-accidentally-publicize-a-post-that-you-didnt/
add_filter( ‘publicize_checkbox_default’, ‘__return_false’ );
to apply to just woocommerce product posts? I.e. all other posts are auto-selected, but product posts have the publicize option, but aren’t auto-checked.
Any thoughts?
Untested, but probably can apply the principles from http://stackoverflow.com/questions/11124525/how-to-detect-custom-post-type-inside-admin-init-hook-callback
In short, need to check if the admin screen we’re looking at is of the product post type, then fire off the filter that you want to use.
I haven’t checked when the Pub filter fires to see if we can add it in that late or not.
Hii Brandon, i am using jetpack and auto publicizing on facebook, twitter, google plus and tumblr. How can i add on instagram and pinterest … is that possible?
That’s not possible. The actual publishing happens via WotdPress.com and additions need to happen there.