PDA

View Full Version : Displaying RSS Feed on website


sydesign
04-16-2012, 09:20 PM
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?

edbr
04-17-2012, 02:11 AM
here's a way of showing a limited niumber of characters but also only showing whole words.

$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

sydesign
04-17-2012, 10:14 PM
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

// 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();
}

edbr
04-18-2012, 03:01 AM
// 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