How to add custom post type in jetpack publicize

While developing a new WordPress plugin for CBSETODAY.COM, I suddenly realized that the website is able to publicize all the default post types of on all the listed social networking websites in Jetpack socialize tool automatically but custom post were excluded.

Jetpack is one of the most used WordPress plugin, right now able to do a lots of task for you and maintained by the developer of WordPress –“Automatic”.

It was ridiculous to notice that jetpack is able to manage all the custom post type supported by automatic itself like Woocommerce but was not allowing me to add my own custom post in his syndication. Why ?

So start digging deeper WordPress then realize that WordPress loop also does not automatically include your defined custom post type on its loop.

Steps to add custom post type in WordPress loop

To make changes in your WordPress loop, add the following code inside your theme’s functions.php file

add_filter( ‘pre_get_posts’, ‘my_get_posts’ );

function my_get_posts( $query ) {

                 if ( is_home() && $query->is_main_query() )

                                $query->set( ‘post_type’, array( ‘post’, ‘course’ ) );

                 return $query;


The above code will force my custom post type in its main loop. ‘Pre_get_posts’ filter add this filter before sending data to the main loop.  In this code  we are only making the changes in only home page.

But the changes will not be available to the syndicated feeds. So if you want to add this custom post type ‘course’ in the feed of this website.  You are also required to  add the following code in place of

Previous if statement. Now your whole query will look this

add_filter( ‘pre_get_posts’, ‘my_get_posts’ );

function my_get_posts( $query ) {

                 if ( is_home() && $query->is_main_query() || is_feed() )

                                $query->set( ‘post_type’, array( ‘post’, ‘course’ ) );

                 return $query;


But the above code will not help you to send this published custom post on social networking site like facebook pages or twitter account.

Jetpack’s publicize feature is very easy to implement but it can not be implemented through functions.php file.  You have to find out the file – where this custom post had been defined.

And make this changes in that file

‘supports’  => array(  ‘title’,  ‘editor’,  ‘excerpt’,   ‘publicize’,   ‘tag’,  ‘thumbnail’    ),

Now your whole code will look something like this.

custom post and jetpack publicize

Custom Post with Jetpack Social publicize support

Now save your work and check the results.

Suggested Similar Articles

9 Brilliant Comments - Join Discussion Now!

  1. Junaid Shahid says:

    Thanks for sharing this amazing feature of jetpack for WP developers this code is really help in future to activate this feature.

    • rakesh says:

      Shahid this feature was always there but it was only supporting posts and pages not custom posts. After jetpack 2.8 they start supporting custom post type but there was a very little knowledge on this topic. Hope you will also use jetpack to automatically publish your contents on social sites.

  2. Junaid Shahid says:

    Dear Rakesh !
    Yes you are right. I am also the user of Jetpack & also used for auto publish the content on social site, but I am also using other plugins too for sharing on more than one account can it is possible with jetpack? because more plugins increased the page load which effects the load time of my website what you said?

    • rakesh says:

      Hi Junaid, Right now jetpack is only sharing with one account. I would suggest you to either use sharebutton by shareit to share the same on multiple social media sites, Jetpack right now share your contents with facebook, twitter, google_, linkedin, path and tumbler. But this is also a great help for us.

  3. I have been using this specific problem from the past couples of months and believe you me that you really help me to rectify this problem related to jetpack. Thanks for sharing this great info…

  4. swarnima says:

    Hi Rakesh
    after this wonderful article, i was really able to solve auto post on social media all my custom post. Thanks a ton for this wonderful guide on jetpack and custom post publicize issue.

  5. Hello Rakesh,

    I have not been using Jetpack a lot but this is really a good information, and I am keeping this for my future reference.

    Thanks for the post.

  6. Can we include ads in between the custom post types?

    • rakesh says:

      Hi Yogesh, You can add ads between the custom post type using ad-injection WordPress plugin. Right now I am using this plugin on my site and this theme is using a lots of custom post types and taxonomies.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>