This is a short blog post, to quickly share with you how to enable automatic social media sharing of custom post type content, in WordPres, via the Jetpack plugins’ Publicise module.
In case you don’t know what the WordPress Jetpack plugin is – and what its Publicize module does – here’s a short backstory: the Jetpack WordPress plugin is a bunch of mini-plugins (called modules) bundled together in one rather awesome WordPress plugin. It’s made by Automattic, the commercial company backing WordPress. They also run WordPress.com – the official, hosted WordPress solution. And that’s how the Jetpack plugin came to fruition: it’s a plugin offering some of the innovations and features from WordPress.com to be used on self-hosted WordPress sites and blogs.
Jetpack is definitely one of the best WordPress plugin. I consider it essential to any WordPress installation! Apart from the Publicise module, you also get:
- Simple statistics, right there in your WordPress dashboard.
- Social sharing buttons that work as intended.
- Spellchecking that warns you about clichés, hidden verbs, complex language, and more.
- Image carousel and fashionable tiled image galleries.
- And sooo much more!
Anyway, to cut a long story short:
I just spend some time activating the Publicize module in the Jetpack plugin and subsequently enabling / setting up the various connections to my Google+, Facebook, Twitter, LinkedIn profiles… and even creating a Path account! Gotta keep up with the Joneses you know! Heck, I even resurrected my old Tumblr profile:) Feel free to befriend me by the way!
But when I went to one of my custom post types… Keine (nada) Publicize settings there! So I started running home to ask my all-knowing bigbrother Google for help.
But did he have an answer? No, not a clear one. Most of the results were forum threads, and most of them dead ends, albeit promising ones at that. So I was ready to abandon my mini-project of getting my custom post types automatically shared via Jetpack’s otherwise neat Publicize module.
But then I found a forum post at the WordPress.org forums, only 1 (one!) day old, announcing:
Hi!
An update to let you know that since Jetpack version 2.8, you cnan now add Publicize support to your Custom Post Types:
http://jetpack.me/2014/01/31/jetpack-2-8-introducing-markdown-and-improving-monitor/
Richard Archambault
Rejoice! Happy dance! And waddya know? It even works!
Simply add publicize to the “supports” array of your custom post type, in the functions.php file, found in your theme folder (provided you’ve created your custom post type there).
Like this:
‘supports’ => array ( ‘title’, ‘editor’, ‘excerpt’, ‘publicize’, ‘thumbnail’, ‘comments’, ‘revisions’, ‘custom-fields’, ‘page-attributes’, ),
And then it works:)
Lucie says
Hello,
Thank you for this tutorial, but for me, that doesn’t work…
Thanks to this code, I display the metabox in the editor for my custom post type, but when I click Publish, my customize post type is not visible on my Facebook page 🙁
Norbert says
Hi Oliver,
Thanks for this tutorial. I followed it to enable Jetpack publicize for my custom post types and it works perfectly.
Oliver Nielsen says
Hey Norbert
You’re welcome:)
Oliver
Bang Nguyen says
Is there anyway to disable publicize feature for custom post type. My site has several post type but I only want to publish normal post to Social networks.
Andi Wilkinson says
Thanks for that! so simple.. .
Tuluzz says
Hi Oliver,
I am using 4 Different Custom Post types – Hardware, Gadgets, Softwares and one more.
But these post types are not created manually but by a 3rd party plugin called – Toolset Types.
So, I am not able to exactly follow the process, how to add support for Jetpack Publicize to custom post types in this case?
Can you please help me out?
Oliver Nielsen says
Hey Tuluzz
Have you tried asking the Toolset Types developers? That may easily be able to help you with it.
=)
Oliver
Kalle Kallovsky says
Even if this comment is a few years old, for me this thread was still useful. And in case somebody stumbled into the same problem as you do, just use this function instead to add the “publicize” functionality after the custom post type was added:
add_post_type_support(‘my_custom_post_type’, ‘publicize’);
The whole call with hooking in for your functions.php could look like this:
add_action(‘init’, ‘add_publicize_to_my_custom_post_type’);
if (!function_exists(‘add_publicize_to_my_custom_post_type’)) {
function add_publicize_to_my_custom_post_type(){
add_post_type_support(‘my_custom_post_type’, ‘publicize’);
}
}
Oliver Nielsen says
Hey Kalle
Thank you so much for sharing that helpful tip. Very gracious of you!
May you have a truly blessed day:)
Oliver
Heather says
Ugh. This actually broke my site. 🙁 I guess they didn’t fix it as well as they thought they did.
Sarah says
Exactly what I was looking for! Thank you!
Syl says
Hello every one,
That you for this post but i still can’t display sharing icons on my custom post types with jetpack.
I added ‘publicize’ tu the line “supports” of my custom post type but did not change anything.
Isn’t there a code to writ in the template that displays the specific custom post type ?
For example, to get the title form an article, you need to write . Is there a line to insert so ?
Thank you very much for your help.
Oliver Nielsen says
Hey Syl
The Publicize module doesn’t add sharing icons – it adds auto-sharing of your post, once it gets published. For sharing buttons you need to activate that other module;)
Oliver
Rahul Negi says
Simple do changes in this file if you want to remove publicize from wp default posts:
On line 6480
function post_type_is_publicizeable( $post_type ) {
if ( 'post' == $post_type )
return false; // make it false
if ( 'custom-post-type1' == $post_type )
return true; // make it true for cpt
if ( 'custom-post-type2' == $post_type )
return true;// make it true for cpt
return post_type_supports( $post_type, 'publicize' );
}
Thanks and enjoy open source
Rahul Negi says
file name is: jetpack/modules/publicize/publicize.php
Rahul Negi says
You have to change on this file: jetpack/modules/publicize/publicize.php
Robert Harper says
If you want Publicize to work with a custom post type that is being set by a plugin then you can use this code in your functions.php file to add the support for that post type:
add_action(‘init’, ‘my_custom_init’);
function my_custom_init() {
add_post_type_support( ‘custom_post_type’, ‘publicize’ );
}
Oliver Nielsen says
Thanks for sharing Robert! Kind of you!
=)
Oliver
Simon Wood says
Thanks Oliver & Robert both – these snippets are exactly what I needed (with both my own & 3rd party custom post types).
Oliver Nielsen says
You’re welcome Simon! Thanks for letting us know!
=)
Oliver
Josh says
Hello, I used your little snippet code to add the publicize to Add Job section in WP Job Manager, but publicize is still not working. The plugin itself has publicize enabled in its functions ‘supports’ section but its not showing up on the add job section,. and I have checked that jetpack publicize is enabled and I have a 2 shared connections linkedin and twitter, I know its working because it shows up on add post but not add job, any ideas ?
Oliver Nielsen says
Hey Josh
Sadly not. I’m not using Jetpack myself any longer, as my site is on the Rainmaker Platform (a hosted, customized WordPress-based platform) so I can’t readily test it.
my best guess would be a clash of function-names the PHP, or something similar. Also keep an eye on the JS console in the developer tools in your browser – it may have some clues.
Have you tried talking to WP Job Manager’s support/developers? It may be something particular to that plugin.
=)
Oliver
Tan0 says
THANK YOU!
This saves me so much time!
Alinn says
Hi
Thanks
🙂
Andrew says
Anyone know how to take this solution and apply it to the Webcomic plugin using the inkblot theme? I can’t publicize my webcomics.
Spadequa says
Worked perfectly. You are a prince.
Nick says
I am trying something simpler–add the Jetpack publicize box to “Pages” and not just to posts. Pages aren’t set up as a custom post type, but it should be similar. Can you help me out with what I would add to functions.php?
Joe says
I believe you can accomplish this using the settings found under Dashboard>Settings>Sharing. There is a series of checkboxes at the bottom of the page to activate and deactivate the share box on various types of content.
Bridget says
Thanks! This is exactly what I needed to get Publicize working with a custom post type. This saved me a lot of time.
Oliver Nielsen says
Glad to hear it was of Help Bridget!
=)
Hakob says
Hi,
I tried to find out how to put it in Place with the Realhomes Template, but no Solution.
Do you have a hint or solution how to get that doen?
Hakob.
Oliver Nielsen says
Hello Hakob
Nope, not familiar with that theme. But if there isn’t a functions.php file in your themes root folder, you create it there, or make a child theme and create it there:)
Oliver
Chathuranga Arambewela says
Thanks a lot for the tip, mate. ! ive been looking all over the net to find a solution for this. it works like a charm. Thanks again. !
ed says
Good man just what I was looking for. Will try it now.
Cesar Falcao says
Hi Oliver. Maybe I´m a little slow, but what all this about? Publicize feature is that our post go published to any social network set up, so whats this procedure you teach us makes?
Oliver Nielsen says
It enables Publicize for custom post types.
cesarfalcao says
Can you please give a example of what we can achieve with that?
Oliver Nielsen says
You can auto-share custom post type content:) Simple as that.
The Publicize module in Jetpack does not work with custom post types, unless you do what I describe in the blog post.
Brian Reich says
Thanks for blogging this! You just saved me a ton of time digging through Jetpack’s code to figure this one out 🙂
Oliver Nielsen says
You’re welcome Brian!