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

Comments

35 responses to “Jetpack Publicize with WooCommerce Products

  1. Anísio Avatar
    Anísio

    Thanks…your snippet saves me hours of digging 🙂

    1. Brandon Kraft Avatar

      Happy to have helped!

  2. Dale Avatar

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

    1. Brandon Kraft Avatar

      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.

  3. pete Avatar

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

  4. themusicbuddy Avatar
    themusicbuddy

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

  5. David Kudler Avatar

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

    1. Brandon Kraft Avatar

      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.

      1. David Kudler Avatar

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

  6. katarina Avatar

    Thank you very much, Brandon! Very nice tutorial!

  7. Wayne Hesler-Mondore Avatar

    my site crashes if posted to either functions or custom_functions

    1. Brandon Kraft Avatar

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

  8. Wayne Hesler-Mondore Avatar

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

    1. Brandon Kraft Avatar

      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/

  9. Wayne Hesler-Mondore Avatar

    thanks Brandon.. note submitted

  10. fuad47 Avatar

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

    1. Brandon Kraft Avatar

      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.

      1. Fuad Avatar
        Fuad

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

        1. Berk Avatar
          Berk

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

  11. jozefsquare Avatar

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

  12. Alessandro Marengo (@alemarengo) Avatar

    You’re just great, great snippet!

  13. newtoyoushreveport Avatar
    newtoyoushreveport

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

  14. dealslama Avatar

    Thanks a lot man 🙂 realy helpede

  15. Keelan Avatar
    Keelan

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

    1. Brandon Kraft Avatar

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

  16. Neeraj Avatar

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

    1. Brandon Kraft Avatar

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

  17. Lim Socheat Avatar

    Thanks for Sharing! It helps me too much.

  18. plasticsurgeryconnect Avatar

    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?

    1. Brandon Kraft Avatar

      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.

  19. Matt Avatar

    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?

    1. Brandon Kraft Avatar

      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.

  20. hafifeal Avatar

    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?

    1. Brandon Kraft Avatar

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

Leave a Reply