Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Show Latest 5 Wordpress Posts in Homepage - Help Needed!

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-23-2008, 02:00 AM
 
GlobalFusion GlobalFusion is offline
 

Advanced Member
  
Join Date: Feb 2007
Posts: 82
 

Wink Show Latest 5 Wordpress Posts in Homepage - Help Needed!

I▓ve been working on this mod to show the latest 5 posts from the blog in the homepage. Currently we have that functionality with XNews; however, we▓d like to show the blog posts instead.

Steps taken:

1.) Created blog.php to call the latest 5 posts from www.site.com/blog:


PHP Code:
<?php
  $how_many
=5// Number of posts you want to show
  
require_once('blog/wp-config.php'); // Set up path to wp-config.php file ?>
   
  <?php
  $postlist 
get_posts('numberposts=5');
  foreach (
$postlist as $post) :
  
// numberposts=X is the number of posts you want to show?>
  <p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
  <?php endforeach; ?>


When www.site.com/blog.php is entered in the address bar, it shows the 5 latest posts.

2) Then, I created blogspots.tpl in skin1/customer/ to call blog.php located in the root directory:
HTML Code:
<div id="homenews"> {include_php file="blog.php"} </div>

3) Finally, blogspots.tpl was called from home.tpl with:
HTML Code:
{include file="customer/blogposts.tpl}

Now I am getting this error message:
Fatal error: Call to a member function on a non-object in /home/site/public_html/blog/wp-includes/functions.php on line 895

Will appreciate if someone with coding experience can shed some light

Thanks,

Augusto
__________________
------------------------------------------------------------------
X-Cart Gold V 4.1.8 + Mods
Reply With Quote
  #2  
Old 03-26-2008, 10:45 AM
 
hues hues is offline
 

Advanced Member
  
Join Date: Jul 2006
Posts: 90
 

Default Re: Show Latest 5 Wordpress Posts in Homepage - Help Needed!

I am also facing the same problem. I am having problem in including the php file to my pages.

I used the following code on a file and named it category_links.php.

Code:
<?php $how_many=5; //How many posts do you want to show require_once('resources/wp-config.php'); // Change this for your path to wp-config.php file ?> <?php $postlist = get_posts('category=13&numberposts=50'); foreach ($postlist as $post) : ?> <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p> <?php endforeach; ?> <? $news=$wpdb->get_results("SELECT `ID`,`post_title` FROM $wpdb->posts WHERE `post_type`=\"post\" AND `post_status`=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); foreach($news as $np){ printf ("<li><a href=\"%s\">%s</a></li>", get_permalink($np->ID),$np->post_title); } ?> </ol>

when i run this file , it shows me the links to the posts in the category id 13. This shows me the result in the form of links to the posts in this particular category.

Now to include this result in my product page which belongs to the same category I added the following code on the bottom of customer/product.tpl page

Code:
<div> {if $cat eq "274"} <h2> Related Articles</h2> {include file="links.tpl"} </div> {/if}

Here corresponding category Id is 274.

I created another file named links.tpl and tried including the php file in that, but no success.

The product page now shows header2 "Related Articles" but after that it gives me smarty error.

I feel I have reached very near to the solution, but I am certainly missing something very simple . I just need to know now, how to include my php file on my pages, so the result which it shows are available as links on my products page.

I will be very thankful for any help on this issue.

thanks
__________________
X-Cart 4.4.5 ... www.drugteststrips.com
X-Cart 4.4.5 ... www.drugalcoholtest.com

Hues Technologies
http://www.huestechnologies.com
Reply With Quote
  #3  
Old 03-26-2008, 12:23 PM
 
GlobalFusion GlobalFusion is offline
 

Advanced Member
  
Join Date: Feb 2007
Posts: 82
 

Default Re: Show Latest 5 Wordpress Posts in Homepage - Help Needed!

Hues, thanks for your quick response.

The other option I am exploring is the Feedburner snippet, which is basically an html code you add whereever you want the posts to be displayed. I tried it in my email signature and works well. We'll see how well it does in the homepage.

Here is the link from feedburner:
http://www.feedburner.com/fb/a/publishers/buzzboost

I like the idea of adding the posts to product detail pages, categories, sub-categories, etc, that can be handled by a simple html command within the post. I got a free mod in my blog that can show related posts according to keywords that are pull out automatically from the title and metags, or you can enter them manually if needed.

Perhaps this topic is not relevant for many people but us
__________________
------------------------------------------------------------------
X-Cart Gold V 4.1.8 + Mods
Reply With Quote
  #4  
Old 03-28-2008, 05:45 PM
 
GlobalFusion GlobalFusion is offline
 

Advanced Member
  
Join Date: Feb 2007
Posts: 82
 

Default Re: Show Latest 5 Wordpress Posts in Homepage - Help Needed!

To post your latest blog posts in the homepage or anywhere you want follow theses steps:

Open and account with www.FeedBurner.com and make sure your RSS works well.

Activate the BuzzBoost section so you can get the script to be installed in your homepage or anywhere you want it to be.

To maximize your CSS customization, copy and paste the URL provided in the script and enter it in the address bar, so you can see the tags, attributes, etc.


Using the example they gave, enter this URL in your favorite browser
HTML Code:
http://feeds.feedburner.com/LAFD?format=sigpro

That will show you
PHP Code:
document.write('<div class="feedburnerFeedBlock" id="LAFD159715">');
document.write('<p class="feedTitle"><a href="http://lafd.blogspot.com/"><B><A HREF=\"http://lafd.blogspot.com\"><U>LAFD News & Information</U></A>:</B></a></p>');
document.write('<ul>');
document.write('<li><span class="headline"><a href="http://lafd.blogspot.com/2008/03/memorial-services-announced-for-fallen.html">Memorial Services Announced for Fallen Los Angeles Firefighter</a></span>');
document.write('</li>');
document.write('<li><span class="headline"><a href="http://lafd.blogspot.com/2008/03/woman-found-dead-on-beach-in-san-pedro.html">Woman Found Dead on Beach in San Pedro</a></span>');
document.write('</li>');
document.write('<li><span class="headline"><a href="http://lafd.blogspot.com/2008/03/north-hollywood-event-will-support.html">North Hollywood Event Will Support Firefighters</a></span>');
document.write('</li>');
document.write('<li><span class="headline"><a href="http://lafd.blogspot.com/2008/03/los-angeles-firefighter-killed-in-line.html">Los Angeles Firefighter Killed in the Line of Duty</a></span>');
document.write('</li>');
document.write('<li><span class="headline"><a href="http://lafd.blogspot.com/2008/03/custodial-spill-sends-3-hollywood.html">Custodial Spill Sends 3 Hollywood Workers to Hospital</a></span>');
document.write('</li>');
document.write('<li><span class="headline"><a href="http://lafd.blogspot.com/2008/03/welding-sparks-warner-center.html">Welding Sparks Warner Center Construction Site Blaze</a></span>');
document.write('</li>');
document.write('</ul>');
document.write(' <div id="creditfooter"><a href="http://www.feedburner.com" target="_blank"><img src="http://www.feedburner.com/fb/images/buzzboost-pwrd.gif" alt="Headlines by FeedBurner" style="border:0"/></a></div>');
document.write('</div>'); 

For more details on CSS customization read http://blogs.feedburner.com/help/buzzboost/using_buzzboost/popup/

If you don▓t want to show the FeedBurner logo image, use this hack in skin1.css:
HTML Code:
#creditfooter img{ display:none; } #creditfooter embed{ display:none; }

Keep in mind that even though the logo was hidden, the FeedBurner.com link embedded in the script will still remain there. If you know of a hack to remove the link, please post it.

That▓s it┘ Enjoy it!

Augusto
__________________
------------------------------------------------------------------
X-Cart Gold V 4.1.8 + Mods
Reply With Quote
  #5  
Old 03-28-2008, 08:05 PM
 
hues hues is offline
 

Advanced Member
  
Join Date: Jul 2006
Posts: 90
 

Default Re: Show Latest 5 Wordpress Posts in Homepage - Help Needed!

Thanks Augusto,

This works perfect, when we want to show recent posts on the blog.

I just need to know how to get feeds for specific category only, so that I can add them on my product pages.
__________________
X-Cart 4.4.5 ... www.drugteststrips.com
X-Cart 4.4.5 ... www.drugalcoholtest.com

Hues Technologies
http://www.huestechnologies.com
Reply With Quote
  #6  
Old 03-28-2008, 08:29 PM
 
GlobalFusion GlobalFusion is offline
 

Advanced Member
  
Join Date: Feb 2007
Posts: 82
 

Default Re: Show Latest 5 Wordpress Posts in Homepage - Help Needed!

You should check some wordpress plugins that may allow you create feeds for specific categories of your blog. I have a mod that separates feeds for full posts and summaries, not sure though if that will help you achieve what you want. check it out http://www.scratch99.com/wordpress-plugin-dualfeeds/
__________________
------------------------------------------------------------------
X-Cart Gold V 4.1.8 + Mods
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:05 PM.

   

 
X-Cart forums © 2001-2020