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' );
}

Posted by Brandon Kraft

My life is an open-source book.

35 Replies to “Jetpack Publicize with WooCommerce Products

  1. Thanks…your snippet saves me hours of digging 🙂

    Reply

  2. Is it possible to edit which parts of a product are auto posted? Where are the posts placed together?

    Reply

    1. 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.

      Reply

  3. 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 .. 🙂

    Reply

  4. themusicbuddy March 16, 2014 at 00:19

    hello, i tried the code above but it doesn’t work. i use wootheme mystile and have jetpack & woocommerce plugin installed.

    Reply

  5. Thanks! In case anyone else is nervous about whether to close of the PHP with a ?>, mine worked fine without.

    Reply

    1. 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.

      Reply

      1. Yup. But the functions.php file for my theme closed the tag, and I was nervous about it. So there you go.

        Reply

  6. Thank you very much, Brandon! Very nice tutorial!

    Reply

  7. my site crashes if posted to either functions or custom_functions

    Reply

    1. Don’t include the opening <?php if you’re adding this to an existing file.

      Reply

  8. doesn’t post anything.. shows options in post writer but never actually posts

    Reply

    1. 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/

      Reply

  9. thanks Brandon.. note submitted

    Reply

  10. I want to share previous posts published before i added this code, but it lets mme to share only new posts.Any idea?

    Reply

    1. 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.

      Reply

      1. Thank you for answering, I have found a piece of code in the internet to tackles this issue.

        Reply

        1. Hi Fuad, could you tell what kind of solution you find, I am still looking and was not lucky to find something yet…

          Reply

  11. .. 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 ..

    Reply

  12. newtoyoushreveport November 2, 2014 at 01:29

    Sweet snippet! Thanks for sharing! You’ve saved me dude!

    Reply

  13. Thanks a lot man 🙂 realy helpede

    Reply

  14. Hi is there a way to grab updated products? And re-post them to twitter/facebook etc?

    Reply

    1. Not as it stands now. This issue will need to be resolved first before something like this is possible.

      Reply

  15. doesn’t post anything.. shows options in post writer but never actually posts

    Reply

    1. It still works for me. It may be an issue with your site’s connection to WordPress.com.

      Reply

  16. Thanks for Sharing! It helps me too much.

    Reply

  17. 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?

    Reply

    1. 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.

      Reply

  18. 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?

    Reply

    1. 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.

      Reply

  19. 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?

    Reply

    1. That’s not possible. The actual publishing happens via WotdPress.com and additions need to happen there.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *