Mobile-Menu iFuturz Infoweb Inc. Contact Portfolio

04

Jul

Display Latest Blog post from blog site in your website

Display Latest Blog post from blog site in your website

Posted On : July 4, 2013

| No Comment

Sometimes you need to display latest published blog posts from blog on your website.

So, for that you can use any plugin like “KB Advanced RSS Widget“. Or can display using complex database connections (if have database details).

But, the recently published posts of any blog page can be displayed on your website using simple code also.

Code 1 :

Add below code in themes function.php file :

if (!function_exists(“curl_get_contents_2″)):

function curl_get_contents_2($url) {

$curl = curl_init();

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl, CURLOPT_URL, $url);

$html = curl_exec($curl);

curl_close($curl);

return $html;

}

endif;

Code 2 :

Add below code where you want to display latest posts.

<?php echo curl_get_contents_2(‘full_url_of_blog_site’ .

‘?j_get_latest_posts=1&j_num_latest_posts=2&j_num_latest_words=20′); ?>

Screenshot :

  • Tags:

Comment