How to add custom post type in jetpack publicize

custom post and 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.

Before Editing your functions.php file it is always advisable to take backup of your theme and do the needful off line then update the same using FTP

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

Now save your work and check the results.


The Whole concept was developed by the man you are watching here. I am rakesh Kumar Serial Niche Blogger and SEO Enthusiast. find me onfacebookandon twitter.. Developed popular WordPress theme for Wallpapers and funny Image WordPress theme. Love SEO optimized WordPress theme Designing and Customization.

Latest posts by rakesh (see all)

Related Posts

9 thoughts on “How to add custom post type in jetpack publicize”

    1. 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 http://cbsetoday.com and this theme is using a lots of custom post types and taxonomies.

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

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

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

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

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

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

Leave a Reply

Your email address will not be published.