Re: Display latest Wordpress Posts
Here's my solution using RSS and a Smarty plugin to pull the latest posts from any wordpress blog.
Create this file include/templater/plugins/function.sr_wpfeed.php: PHP Code:
Then in whatever template you want to display the posts in you can display the posts something like this: Code:
{sr_wpfeed var="someposts" wpsite="http://www.snowriver.com/uggs-and-more" num=2} This should work in any version of X-Cart as it doesn't use any X-Cart functions. Also there are no modifications to X-Cart php code so it doesn't get wiped out by upgrades. |
Re: Display latest Wordpress Posts
This didn't work for me. My site is *.co.uk and my blog is *.co.uk/blog/.
I copied everything 100%, then just changed the URL to match my wordpress blog homepage. What did I do wrong? |
Re: Display latest Wordpress Posts
p.s. I currently use simplepie to display RSS feed snippets. Could there be a conflict?
|
Re: Display latest Wordpress Posts
Sorry, my example usage has a mistake. You need to use $somepost instead of $someposts inside the foreach loop like this:
Code:
{sr_wpfeed var="someposts" wpsite="http://www.snowriver.com/uggs-and-more" num=2} |
Re: Display latest Wordpress Posts
Hi,
I added: Code:
{sr_wpfeed var="someposts" wpsite="http://www.promartsupplements.co.uk/blog" num=2} but I got the following errors: Warning: simplexml_load_file() [function.simplexml-load-file]: http://www.promartsupplements.co.uk/blog//feed:1: parser error : Document is empty in /home/promarts/public_html/include/templater/plugins/function.sr_wpfeed.php on line 91 Error: Smarty error: Error reading XML file in /home/promarts/public_html/Smarty-2.6.19/Smarty.class.php on line 1092 Warning: Invalid argument supplied for foreach() in /home/promarts/public_html/include/templater/plugins/function.sr_wpfeed.php on line 95 Any ideas what is causing the errors? Thanks, |
Re: Display latest Wordpress Posts
That's puzzling as http://www.promartsupplements.co.uk/blog//feed properly returns the XML data so it shouldn't be empty. If you have ssh access on your server what does this do?:
wget http://www.promartsupplements.co.uk/blog//feed If that can't download the XML and you can in a browser check with your host to see why you can't load local URL's. |
Re: Display latest Wordpress Posts
Just installed this for a client - works great. Thanks Ralph
|
Re: Display latest Wordpress Posts
Saw just one glitch - double and single quotes in description are converted to some other characters (I suspect some toher special characters are affected as well). I tried html_entity_decode and htmlspecialchars_decode but no luck. Do you have any idea Ralph?
|
Re: Display latest Wordpress Posts
That's Wordpress converting quotes to smart quotes. Here's a link on how you can turn them off in Wordpress:
http://www.lancebledsoe.com/how-to-turn-off-wordpress-smart-quotes/ If you want to leave them as smart quotes on your wordpress blog but convert them back for the RSS feed you'll need to add some code to convert them. Here's a discussion of how that can be done. http://shiflett.org/blog/2005/oct/convert-smart-quotes-with-php |
Re: Display latest Wordpress Posts
Thanks Ralph
|
All times are GMT -8. The time now is 06:10 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.