logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-16-2012, 08:20 PM   #1
sydesign
 
Join Date: Jan 2011
Posts: 41
Default Displaying RSS Feed on website

i would like to have my Wordpress blog posts shown on my homepage whenever they are posted.

I've seen a number of tutorials showing how to do it, however, they all just show how to display a short description of the post. is there a way i can display only a certain amount of characters or words of the latest post, other than the usual 255 or so that most of them default to?
sydesign is offline   Reply With Quote
Old 04-17-2012, 01:11 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

here's a way of showing a limited niumber of characters but also only showing whole words.

Code:
 $text=$row['text'] ; 	
$position=130; // Define how many characters you want to display.


$post = substr($text,$position,1); // Find what is the last character displaying. We find it by getting only last one character from your display message.

if($post !=" "){ // In this step, if last character is not " "(space) do this step .

// Find until we found that last character is " "(space)
// by $position+1 (14+1=15, 15+1=16 until we found " "(space) that mean character 20)
while($post !=" "){
$i=1;
$position=$position+$i;

$post = substr($text,$position,1);
}

}

$post = substr($text,0,$position); // Display your message ?>
so echo out $post in this example
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 04-17-2012, 09:14 PM   #3
sydesign
 
Join Date: Jan 2011
Posts: 41
Default

how would i implement that into showing my Wordpress RSS feed?

thank you for your help! I'm not very fluent in my PHP or how to use it fully.

the code I'm using is

PHP Code:
         // Include the file that does all the work
         
include("rssreader.php");
      
         
// This is the URL to the actual RSS feed. Change this value
         // if you want to show a different feed.
         
$url="http://hooksettersunion.net76.net/blog/?feed=rss2";
      
         
// Create an instance of the rssFeed object, passing it
         // the URL of the feed
         
$rss=new rssFeed($url);
      
         
// If there was an error getting the data
         
if($rss->error){
            
// Show the error
            
print "<h1>Error:</h1>\n<p><strong>$rss->error</strong></p>";
         }else{
      
            
// Otherwise, we have the data, so we call the parse method
            
$rss->parse();
      
            
// Show the news stories
            
$rss->showStories();
         } 
sydesign is offline   Reply With Quote
Old 04-18-2012, 02:01 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

// Include the file that does all the work
include("rssreader.php");

says it really, you would have to write a new method for this file or extend the existing showStories() i would say
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:55 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com