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