millsy007 Posted December 11, 2008 Share Posted December 11, 2008 I have a wordpress blog in a subdirectory of my site, I want to keep it seperate from the rest of my site, but would like to access the latest posts on my sites homepage. I am trying to do this by reading the blog feed and displaying it but the code I have found relies on a wordpress function, but as I have this installed on a different section of my site I cant access that functionality. Is there a way I could modify the following to get out what I need? <?php require_once(ABSPATH . WPINC . '/rss-functions.php'); $rss = fetch_rss('http://www.mysite.nl/blog/rss'); echo '<ul>'; for($i=0;$i<5;$i++) { $item=$rss->items[$i]; echo '<li><a href="' . $item['link'] . '" title="' . $item['title'] . '">' . $item['title'] . '</a></li>'; } echo '</ul>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/136511-displaying-my-blog-feed/ Share on other sites More sharing options...
premiso Posted December 11, 2008 Share Posted December 11, 2008 I would look into: simple_xml in replace of fetch_rss Quote Link to comment https://forums.phpfreaks.com/topic/136511-displaying-my-blog-feed/#findComment-712550 Share on other sites More sharing options...
millsy007 Posted December 11, 2008 Author Share Posted December 11, 2008 Thanks, my server wont let me do the: include 'http://www.beachhostel.nl/blog/rss'; as: 'URL file-access is disabled in the server configuration' and I cant work out where the actual http://www.beachhostel.nl/blog/rss file is!? Quote Link to comment https://forums.phpfreaks.com/topic/136511-displaying-my-blog-feed/#findComment-712572 Share on other sites More sharing options...
premiso Posted December 11, 2008 Share Posted December 11, 2008 Describe what you mean when you say "different section". A different domain name or just a different directory IE: beachhostel.nl/newdirectory/newfile instead of beachhostel.nl/blog/rss Quote Link to comment https://forums.phpfreaks.com/topic/136511-displaying-my-blog-feed/#findComment-712593 Share on other sites More sharing options...
millsy007 Posted December 11, 2008 Author Share Posted December 11, 2008 All my wordpress files are contained within www.mywebsite.nl/blog But I want to show a list of the posts on www.mywebsite.nl/index.php So far as I know I can't access the functions in the wordpress codex because of this? Quote Link to comment https://forums.phpfreaks.com/topic/136511-displaying-my-blog-feed/#findComment-712619 Share on other sites More sharing options...
flyhoney Posted December 11, 2008 Share Posted December 11, 2008 You could pull the posts from the wordpress database with code something like this: <?php $query = " SELECT post_date, post_title, post_content, guid FROM `wp_posts` ORDER BY post_date DESC LIMIT 0,5"; $result = mysql_query($query); foreach ($post = mysql_fetch_object($result)) { ?> <div class="post"> <div class="post_title"> <a href="<?= $post->guid ?>"><?= $post->post_title ?><span class="pdate"><?= $post->post_date ?></span></a> </div> <div class="post_content"><?= $post->post_content ?></div> </div> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136511-displaying-my-blog-feed/#findComment-712632 Share on other sites More sharing options...
millsy007 Posted December 11, 2008 Author Share Posted December 11, 2008 I get: Parse error: syntax error, unexpected ')' But all the brackets seem to add up? Quote Link to comment https://forums.phpfreaks.com/topic/136511-displaying-my-blog-feed/#findComment-712991 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.