Effective ways to publish wordpress posts on socialengine

WordPress is a very popular and famous CMS for the blogging purpose. Lots of people use its blogging power to express their views or skills or knowledge. But if an organization shares  experience through blogs, then they do not want to restrict to a single website. They definitely wants to spread their experience on other sites as well. But posting a same blog on two different websites is a very time consuming process.

We encounter this problem with one of our client “The Science Advisory Board ”, who has a large number of wordpress posts and they want to show them on their social community site as well. But writing a large no of same blogs on two sites are very time and cost consuming for them.We recommended our client a solution to automate the blog posting on SocialEngine by using custom plugin built for socialengine and wordpress. In this article we are going to demonstrate, how we can display wordpress posts on socialengine automatically.

After a little bit of configuration we are not only able to show blogs on social networking site, but also we can filter them on the basis of recent blog, popular blog, etc. and it will automatically update the blog on socialengine, if any new blog posts on wordpress.

Lets dive into WordPress Development

We will create a main.php file in controllers, which will consist of various functions which will give the posts, categories, tags, etc.

function feed_wpfeed() will give us all the necessary details of the posts such as post title, postparmalink, author, etc. in the xml format.

function feed_wpfeed(){
           // it will gives all the blogs details of the blogging website.
	}

likewise for getting categories and tags of the wordpress we will use the function feed_category() and function feed_tags().

function feed_category(){
  // it will give us all the categoies available in the wordpress
}

 

function feed_tags(){
   // it will gives us the tags available
}

Now we will call the “add_feed” hook for all the three functions which are given above . “add_feed” hook will add a new feed type which can be call by entering the url with new feed type. For adding a activity in socialengine on  posting a blog in wordpress we will call the “publish_post”  hook which will call the “post_activity_feed”  function everytime, when a new blog is posted in the blogging website.  The “post_activity_feed” will send all the necessary details to the socialengine website through curl call.

function post_blog_comment( $comment_ID, $comment_status ) {
// send all the necessary details of blog to socialengine
}

For Adding a activity in socialengine when someone add a comment on any post in wordpress we will call “comment_post” hook, which will call “post_blog_comment” function whenever someone add a comment.“post_blog_comment” will send all the necessary details to the socialengine website through curl call.

function post_blog_comment( $comment_ID, $comment_status ) {
// send necessary detail to social networking website
}

 Lets dive into SocialEngine Development

To get the blogs we need the url of the blogging site, based on that url we will get all the feed in the xml format, which we has been created in the wordpress. For store the wordpress url we will create a admin controller and a form which will store the entered url in the database.

 

Blog-adminsettings

For the display settings of blogs widget we need a interface in the admin panel. To do so we will create a form in the Content.php file under settings folder of socialengine.

Widget-settings

For the filtration process of blogs based on category and tags we needs to import them from blogging website. we will use a php function “file_get_contents($url)”. “file_get_contents()” gives the content in xml format based on the given url. to convert it we will use “SimpleXmlElement($content)”  function.

$content = file_get_contents($feed_url);
	if($content){
	 	$feeds = new SimpleXmlElement($content);
         //.........gives us the content in xml format based on the url given.

After getting the categories and tags we can filter blogs. To display blogs in socialengine we will create a widget and extract feeds from blogging site based on the filtration set by the user in the widget settings.

blog-socialengine

Conclusion

Hence by using this approach, we can display wordpress blogs in socialengine community. To Reduce your effort we have created a plugin  by which you can display wordpress posts on social networking. please contact us, If you have any query.

Leave a Comment

Scroll to Top