+ All Categories
Home > Documents > Import and Display RSS Feeds in Wordpress.pdf

Import and Display RSS Feeds in Wordpress.pdf

Date post: 05-Oct-2015
Category:
Upload: prime-realty-ventures
View: 25 times
Download: 0 times
Share this document with a friend
Description:
Import and Display RSS Feeds in Wordpress.pdf
Popular Tags:

of 25

Transcript
  • Perishable Press

    Import and Display RSS Feeds in WordPressPublished Sunday, April 26, 2009 @ 2:35 pm 53 Responses

    Importing and displaying external RSS feeds on your site is a great way to share your online activity with your visitors. If you are active on Flickr, Delicious, Twitter, or Tumblr, your visitors will enjoy staying current with your updates. Many social media sites provide exclusive feeds for user-generated content that may be imported and displayed on virtually any web page. In this article, you will learn three ways to import and display feed content on your WordPress-powered website without installing yet another plugin.

    On the menu for this tutorial:

    Importing and displaying feeds with WordPress & Magpie (simple method)Importing and displaying feeds with WordPress & Magpie (advanced method)Importing and displaying feeds with SimplePie (WordPress not required)

    Sound good? Lets get to it..

    Importing and displaying feeds with WordPress & Magpie (simple method)

    If you only need to display the titles of a feed, you can take advantage of the built-in WordPress function, wp_rss(), which provides WordPress with essential feed-fetching and feed-parsing functionality. All you need to do is place the following code into the desired display location within your theme template file (e.g., sidebar.php):

    In the first line, we include the required wp_rss() function from the rss.php file (rss-functions.php in older versions of WordPress). In the second line, we specify two parameters: the first is our feed URL and the second is the number of titles to display. Simply edit these two parameters and enjoy the results.

    Importing and displaying feeds with WordPress & Magpie (advanced method)

    Magpie provides an XML-based RSS built with PHP. WordPress uses Magpie to parse RSS and Atom feeds and display them on your website. Magpie parses feeds for two different WordPress functions:

    wp_rss() - fetches and parses feeds for instant/automatic outputfetch_rss() - fetches and parses feeds for advanced/customized output

    Page 1 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Each of these functions uses the Snoopy HTTP client for feed retreival, Magpie for feed parsing, and RSSCache for automatic feed caching.

    The wp_rss() function fetches and parses feed content and then outputs an unordered list containing each of the feeds post titles (see previous section). The fetch_rss() also fetches and parses feed content and will output the results according to your specific script configuration. Instead of just spitting out titles, the fetch_rss() function enables us to display any available feed data in customized format. Lets look at an example.

    Once placed in the desired location in your WordPress theme template file, the previous code will output the title and description (content) of the seven most recent feed items. Simply edit the three variables in the first three lines of the script and you are good to go. Then, once you see that everything is working as intended, feel free to modify the markup as you see fit. Before moving on, lets walk through the method in sequential fashion:

    Include the script - specify the path to rss.php (or rss-functions.php in older versions of WordPress)

    Specify your feed URL - specify the URL of the feed you would like to displayLimit number of items - edit the two numbers to reflect the numbers of the first and last feed items, respectively

    Empty check - before running the loop, check that the feed isnt emptyBegin the loop - begin the standard foreach loopDisplay the items - for each feed item, display the post title, title link, and post contentWrap it up - close the loop and end the empty check

    Notes on using WordPress/Magpie If you are calling feeds that may or may not include a description, you may want to avoid the output of empty paragraph elements ( ) by wrapping the description with a conditional check like so:

    Also, if the feed isnt showing, try replacing the associated line with this:

    $feed = @fetch_rss('http://domain.tld/your-feed/');

    For an alternate way of checking for the presence of a working feed, replace the empty check with this:

    Page 2 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • You can also clean up feed output by taking adavantage of WordPress built-in filtering functionality:

    Here are some of the variables that are available from your feeds (not sure if all of these work):

    $item['link'] - post permalink$item['title'] - title of the post$item['pubdate'] - post publication date$item['description'] - post excerpt or content$item['creator'] - post author (does this work?)$item['content'] - post content (does this work?)

    Note that when using the $item['pubdate'] variable, the default output will look like this:

    Mon, 11 Jul 2050 01:11:11 +0000

    Fortunately we can clean this up a little bit by parsing it with PHPs substr() function like so:

    $pubdate = substr($item['pubdate'], 0, 16);

    Which will output the following date format:

    Mon, 11 Jul 2050

    And, finally, an alternate loop format that defines the number of items to display without using the array_slice() function:

    Importing and displaying feeds with SimplePie (WordPress not required)

    For more robust feed fetching in the most simple way possible, SimplePie is the perfect choice. SimplePie is a blazing fast PHP class that is easy to learn and simple to use. With a few quick steps, you can use SimplePie to retrieve and parse any RSS or Atom feeds and display them on any PHP-enabled website (WordPress is not required). SimplePie works great with its default settings, but it is also highly customizable. You can use SimplePie to display any type of data from any number of feeds, and it even works without WordPress. Sound good? Heres how to setup SimplePie in three easy steps:

    Download SimplePie and unzipPlace the simplepie.inc into a folder named php located in the web-accessible root directory of your website

    Create a folder named cache (also in the web-accessible root directory) and make sure that its writable by the server (i.e., CHMOD to 755, 775, or 777)

    Thats all there is to it. Once SimplePie is properly setup on your server, you may check that its working by uploading the following code to the web page of your choice (edit as specified):

  • If the feed title and description dont appear on the page, check the path to simplepie.inc in the first line and also verify that the feed URL is correct and that the feed is working properly.

    Once everything is working and flowing like butter, the possibilities are endless. To get you started, lets expand the previous testing code to include the title, link, content and date for the seven most recent feed items:

  • Begin the loop - standard foreach loop with parameterized argument for setting the number of feed items to display

    4.

    Feed items - for each feed item, display the post title, title link, post content, and post date.5.End the loop - terminate the recursive processing of feed items6.Else condition - if the $check variable is not set, then display the following code7.Else message - text/markup to display if the initialization check fails and the feed is not displayed

    8.

    End the if condition - conclude the script by terminating the if condition9.

    Notes on SimplePie It is possible to merge feeds into a single stream by replacing the associated lines with the following:

    Also, you can truncate the number of words that appear in the content of each feed item by using PHPs substr() function:

    In the foreach() loop, you may specify the number of the first and last feed to process by editing the 0 and 7 in the following line:

    For WordPress users who would rather not mess with all of the under-the-hood code stuff, there is an awesome SimplePie plugin that automates just about everything. It should be noted, however, that the SimplePie plugin consists of two different plugins and requires a significant amount of time and effort in order to implement. Its a great set of plugins, but I would argue that the manual implementation method is easier.

    Finally, keep in mind that your feeds are cached according to either the default setting or your specified cache duration. The default caching duration is one hour, which is suitable for most implementations. Dont forget that, for caching to work, SimplePie must have write access to the cache directory (see above).

    With SimplePie, the options are endless. This tutorial is enough to get you started, but you should check the SimplePie Wiki for more comprehensive documentation.

    Feed em!

    With these versatile, easy-to-use techniques for importing and displaying external feeds, virtually anything is possible. If you are using WordPress, you can take advantage of the built-in Magpie functionality and display feeds quickly and easily. For non-WordPress users or for those seeking more control over the feed importation and display process, you will find all of the flexibility you need with SimplePie. These methods will help you provide more content to your readers and do so without getting locked into using yet another needless plugin. So go forth and feed that insatiable audience of yours! :)

    Page 5 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Copyright2009PerishablePress

    About this article

    This is article #686, posted by Jeff Starr on Sunday, April 26, 2009 @ 2:35pm. Categorized as WordPress & tagged with feed, loops, php, rss, tips, tricks, tutorials, WordPress. Updated on May 19, 2009. Visited 71575 times. 53 Responses

    SubscribeBookmarkTrackback

    Related articles

    Consolidate and Localize Your WordPress FeedsMiscellaneous Code Snippets for WordPress, Windows, and FirefoxHorizontally Sequenced Display Order for WordPress Posts in Two Columns3 Ways to Exclude Content from WordPress FeedsRedirect WordPress Individual Category Feeds to Feedburner via HTAccessDisplay Random Posts from Specific Tags or CategoriesRedirect WordPress Feeds to Feedburner via htaccess (Redux)

    Dialogue53 Responses Jump to comment form

    1 Peter Westwood

    April 27, 2009 at 12:06 am

    SimplePie is in trunk for WordPress 2.8

    It would be good to update this to include what will be available then!

    2 Jeff Starr

    April 27, 2009 at 7:09 am

    Yes, I thought about waiting until 2.8, but figured I could just update the article when it is released. I am looking forward to SimplePie and WordPress working together hopefully it will mean even more flexibility for designers and developers. Cheers!

    3 Frank

    April 28, 2009 at 2:33 am

    Nice post! I think it is better for the date you use the function of WordPress for formating the date with the options of the blog: $pubdate = date_i18n(get_option('date_format'), $pubdate); Best regards Frank

    4 Jeff Starr

    Page 6 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • April 28, 2009 at 9:20 am

    Excellent tip, Frank thanks! :) The workaround mentioned in the post was a bit insufficient. This looks like it will work much better. Thanks for sharing!

    5 Frank

    April 28, 2009 at 11:21 pm

    @Jeff: thanks for your answer; a small modification for my tipp: $pubDate = date_i18n( get_option('date_format'), strtotime( $item['pubdate'] ) ); This works fine and the return is a date in the format of the blog-options.

    6 Jeff Starr

    April 29, 2009 at 9:21 am

    @Frank: Perfect! Thank you for the follow-up :)

    7 teddY

    May 1, 2009 at 11:15 pm

    Wow, a really handy tutorial, Jeff! If it werent you writing this tutorial, I wouldnt have found a way how to parse my Digg feed so that I can display it on my blog. I know that Wordpress has a function to import a RSS feed, but I have no idea how to process the information contained in it. Your guide saved me from all the need of Googling and piecing together snippets of code from all kinds of webpages, especially for the parsing of the time (pubdate). I have no clue how to change the way it is displayed until you wrote about it.

    Im considering to install a WP plugin called Lifestream to better manage all my social website activities (mainly Twitter, Digg and Flickr), and it seems to be a nice nifty plugin to try out. Of course, if it all fails, I can always use your failsafe method :)

    8 Thomas Scholz

    May 4, 2009 at 10:12 am

    Passing an URL to the SimplePie constructor triggers the automatic modus. Any later configuration attempts will fail. See: http://simplepie.org/wiki/reference/simplepie/start for details.

    9 Jeff Starr

    May 4, 2009 at 11:50 am

    @teddY: Always good to hear from you! Yes there are tons of great ways to use the feed-importing methods described in this article. There are many configurational options and different ways to use this type of functionality not just with social media feeds, but with any other type of feed imaginable. I have several blogs to which I regularly publish content, and so having an easy way to import the various feeds makes it easy to display all of my content in one place.

    The Lifestream plugin for WordPress looks pretty cool. I recently discovered Sweetcron, which is a robust and standalone (& self-hosted) lifestream application. Its pretty cool I setup a test site and have been playing around with it, but there is tons of configurational options and stuff you can

    Page 7 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • do with it. I have seen some pretty sweet implementations around the Web. Maybe something to check out! :)

    10 Jeff Starr

    May 4, 2009 at 12:12 pm

    @Thomas Scholz: The article has been updated with the correct information. Thanks!

    11 davis

    May 11, 2009 at 1:44 pm

    Jeff,

    Thanks for this! Works perfectly and easily! I have, hopefully, a quick question for you though.

    Using Wordpress/Magpie advance as listed above:

    What about if i want to pass a variable for the URL.

    Maybe an RSS feed URL listed in the User.

    I have this to echo the user name(s) field value(s) (using a plugin to create a custom field in which i place the url) :

    $values = get_cimyFieldValue(false, 'TWITTERFEEDURL');

    foreach ($values as $value) { $user_id = $value['user_id']; echo $value['user_login']; echo cimy_uef_sanitize_content($value['VALUE']); }

    But if instead I wanted to pass the text value of that field into $feed = fetch_rss('http://domain.tld/your-feed/');

    How would I do that? My attempts have proven my knowledge lacking ;)

    12 Jeff Starr

    May 12, 2009 at 3:59 pm

    @davis: Ugh! I wish I could help but unfortunately that exceeds my limits of knowledge on the topic as well. Very soon, WordPress 2.8 will be released and will be using SimplePie instead of Magpie. Perhaps this will provide enable you to get the help you need via the actively moderated SimplePie help forum..?

    13 davis

    May 12, 2009 at 4:22 pm

    ah, no worries Jeff.

    Page 8 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • I actually made it work making a variable equal to the function pulling the user field data (in this case being created by a plugin, but would work similarly for the website text field) - then i placed that variable into fetch_rss including all of that in a foreach after the data was retrieved and rss script included.

    in my case (and in the event it helps someone else) the code is this:

    include(ABSPATH.WPINC.'/rss.php'); // path to include script $values = get_cimyFieldValue(false, 'FEEDURL'); foreach ($values as $value) { $user_id = $value['user_id']; $FV = cimy_uef_sanitize_content($value['VALUE']); $feed = fetch_rss($FV); // specify feed url $items = array_slice($feed->items, 0, 3); // specify first and last item echo "".$value['user_login']."";

    foreach ($items as $item) { echo "". $item['title'].""; } echo ""; }

    now im off to try and filter the user role for which all of that is processed - wish me luck! haha.

    thanks again Jeff!

    14 Jeff Starr

    May 12, 2009 at 4:53 pm

    Good luck and thanks for the followup with code solution. Very cool. I tried formatting it with some indentation and whatnot, so let me know if anything is incorrect.

    Now I know who to contact if I ever need some feed-parsing ninja skillz! ;)

    15 Zeeshawn

    May 13, 2009 at 4:04 am

    Awesome article Jeff, Clear , to the point and so easy to follow. Ill be disposing of my plugins and coding up my own code from now on. Love it mate.

    16 mccormicky

    May 13, 2009 at 4:29 am

    Sweet! Now if only I had had all this info last fall. I would have suffered a lot less

    17 Jeff Starr

    May 13, 2009 at 4:09 pm

    @Zeeshawn: Awesome, great to hear it thanks for the feedback! :)

    @mccormicky: I know what you mean. I should have written this article a year ago. I think it took me that long to understand it all myself. Oh well, at least its here for next time! :)

    Page 9 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • 18 Serge

    May 19, 2009 at 8:17 am

    Hi every one, youve done a great piece of code here. I was fighting to get one of my own categories listed as RSS in separate page in vane before ive come here. I m barmen, not a code ninja Just a note about WP 2.7:

    1 i couldnt include my own feed using your code (got a warning for the second display about function array )

    2 have given the feed to google feedburner and set the feed url of the last one

    result: Worked as a swiss watches and fixed as well the problem of the Frenchy letters le etc

    Thanx a lot for your being born. the result is upgrading here : http://www.monmillion.fr/boutique/

    19 Mark

    May 25, 2009 at 10:16 am

    Man, I would love to get what @davis (comment #13) did working on my site but I am so far failing miserably. Help? Thanks!

    20 Jeff Starr

    May 27, 2009 at 7:35 am

    @Serge: Im speechless! Thanks for the feedback :)

    @Mark: I wish I could help here, but I am not familiar with the details of the technique. Hopefully davis will drop in again and lend a hand..

    21 davis

    May 27, 2009 at 9:17 am

    @mark

    one thing to keep in mind before i break this down: the get_cimyFieldValue is a function created by the plugin Cimy User Extra Fields ( http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/documentation/ ) I used it to create a field in the User profile. In this case a text field that i placed an RSS feed url into.

    knowing that, here is the walk through.

    include(ABSPATH.WPINC.'/rss.php'); This is including the RSS magic

    $values = get_cimyFieldValue(false, 'FEEDURL'); This is saying the variable $values is equal to the function created by Cimy User Extra Fields false and FEEDURL are options for that in this case FEEDURL is merely what i named the new text field i created with the plugin.

    Page 10 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • So its essentially just saying that I want $values to be the values of the new fields in the user profile, and Im calling to the new field FEEDURL specifically - again that could be named anything.

    foreach ($values as $value) {

    Here it is saying run this for everyone of them

    $FV = cimy_uef_sanitize_content($value['VALUE']); This line ive created the variable $FV to be equal to another function created by the plugin (one to echo the text of the field i created) and called upon in the $values line above.

    $feed = fetch_rss($FV); // specify feed url - Here im just telling it that $feed is equal to fetch_rss function with a feed value of the variable $FV which i created to call the function cimy_uef_sanitize_content which understands we are looking at the text field value for FEEDURL per the $values = get_cimyFieldValues() line above.

    $items = array_slice($feed->items, 0, 3); // specify first and last item This is styling the $feed

    The rest is echoing to the page. echo "".$value['user_login'].""; This echos the user login name and below it is saying for each $item (that are pulled from $feed, that is fetching from $FV that is equal to cimy_uef_santize_content() that is limited from $values to FEEDURL) echo each feed entry as follows.

    foreach ($items as $item) { echo "". $item['title'].""; } echo "";

    I hope that helps to explain what i did. I still have to figure out how to only apply this whole thing to only one class of users (or to specific users) but i havent jumped back into yet to tackle that one.

    22 Patternhead

    June 5, 2009 at 7:09 am

    Great article Jeff.

    Im using WP 2.71. Does anyone happen to know if Magpie writes the cache to a table or to a file (I read somewhere that it adds entries to wp_options).

    23 Jeff Starr

    June 7, 2009 at 6:09 pm

    @Patternhead: I think you are correct there is no file that I know of that is used by Magpie and no information about setting permissions etc for such a file. If I remember correctly, there is a magpie field in the options table, as you suggest. If anyone has any specific information on this please share. Thx.

    24 westi

    Page 11 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • June 7, 2009 at 10:11 pm

    Yes WordPress does store the cache of the feed in the options table using a number of options (named magpie_x I think).

    WordPress 2.8 feed functions, which now use SimplePie, will also cache in the options table but using the new transients functionality. What this does is store the information in the db unless you have installed an object cache plugin to use some thing like memcache for the WordPress object cache -then the transients are just stored in the cache.

    25 Patternhead

    June 8, 2009 at 12:30 am

    @Jeff @westi Thanks for the info. Thats interesting. So in terms of performance, I wonder which is quicker. Reading the cache from the DB or the disk.

    I prefer to keep the DB as clean as poss so Ive gone for simplepie (not the plugin) but this is a pretty big file 340kb so maybe it would be more efficient to just let WP use the DB for caching.

    Im planning to use 2.8 when we get RC1 so may have to take another look at this issue then. I havent use memcache before. Sounds like an idea for a future post Jeff ;)

    26 Jeff Starr

    June 8, 2009 at 12:47 pm

    @westi: Thanks for posting! :)

    @Patternhead: Yes, that is a great idea for a post! Looking forward to 2.8 :)

    27 Brian

    June 13, 2009 at 8:49 am

    Hi, Thanks for this code. I had it working correctly at one point but made the mistake of including small images in WordPress codes which prevented the RSS feed from working correctly. However when I removed these I found that new items did not appear in the WordPress page although they do in the WordPress feeds. Using phpMyAdmin I have looked at the database expecting to find a file (either the last one displayed on the page or the one after) with some peculiar setting but no. Ive deleted and re-entered all the affected bits but to no avail. The problem is displayed on

    http://www.middlesbroughlourdes.co.uk/latest-news

    where the sidebar links show the correct items but the body doesnt.

    Any ideas?

    28 Brian

    June 13, 2009 at 10:42 am

    Hi, Without doing anything on my part the problem described in my last post has disappeared. Curious. Once again, thanks for the code.

    Page 12 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • P.S. Just for the record I was using WP 2.8 on Safari 4 (Mac) and could see the exact same problem in iCab 4.6.0 and Camino 1.6.7.

    29 Jeff Starr

    June 15, 2009 at 6:14 pm

    @Brian: Glad to hear you got it working thanks for posting the follow-up comment stating that the issue has been resolved. Much appreciated :)

    30 Lekha

    July 21, 2009 at 9:12 pm

    This is by far the best bit of information I have laid my eyes on!!!!!!!

    kudos to you!!!

    31 Ray

    July 22, 2009 at 2:55 am

    Hey Jeff,

    Great post as always! Also great comments by the visitors.

    Didnt know that WP stores RSS cache in the DB. That doesnt sound very nice. I think Im going to go with the manual SimplePie method.

    Just adding my two cents, but probably the lightest RSS parser library is lastRSS. Its also quite extendable, although not as full-featured as SimplePie.

    By the way, you might want to update your tutorial for WP 2.8+ now ;)

    32 Josh

    July 23, 2009 at 1:11 pm

    What if you wanted to include a custom field that is the url to the rss feed? Im having difficulties since its php within php. Do I have to store as a variable first?

    33 Josh

    July 24, 2009 at 1:06 pm

    I figured it out! You need to include global $post.

    ID, 'rss', true); wp_rss($rssfeed, 5); ?>

    34 Josh

    July 24, 2009 at 1:07 pm

    Oops looks like it stripped the code. Let me try that again.

    Page 13 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • : { k w -

    35 Jeff Starr

    July 25, 2009 at 4:43 pm

    Thanks for the follow-up post, Josh glad to hear you got it working :)

    (sorry for the code hassle WordPress likes to gobble PHP!)

    36 Tim

    July 25, 2009 at 7:49 pm

    How can we use the simple pie method described above now with WP 2.8?

    37 Jeff Starr

    July 26, 2009 at 8:22 am

    Hi Tim, as of WordPress 2.8, we can include and display feeds according to the SimplePie documentation. The only difference is that we use this:

    To return the feed as a standard SimplePie object. Everything else is according to the SimplePie documentation.

    38 Corey O

    August 2, 2009 at 6:53 am

    Is there any way to include an image while displaying the feed titles and description?

    39 Jeff Starr

    August 2, 2009 at 3:29 pm

    Hi Corey, I think this may help:

    http://perishablepress.com/press/2007/02/04/feed-your-image-via-atom-or-rss/

    40 Corey O

    August 4, 2009 at 7:17 am

    Thanks Jeff,

    Nice site by the way. The background image is pretty awesome.

    41 John

    August 17, 2009 at 1:00 pm

    Good bits, will pass them along!

    Page 14 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Very useful site overall, thanks for sharing.

    42 WebDev.im

    August 30, 2009 at 8:49 pm

    Very nice site. I will be trying to integrate your feed code into my site pronto. Thanks for the resource.

    43 National Reporter

    September 3, 2009 at 3:46 am

    I was searching for a tool that would help me to feed articles for me to my website and i found it here and i think its very useful stuff , i need more closely look to include it in my wordpress, thanks for sharing and am going to use it in my blog right away.. Thank You.

    Trackbacks / Pingbacks

    Lenguajes X Importar RSS en WordPress sin usar un plugin1.Importar RSS en WordPress sin usar un plugin | Blog Ascariz2.Enlaces de la semana (III) | Mareos de un geek3.links for 2009-05-27 Rob Parker robparker.org.uk4. Importar RSS en WordPress5.WordPress/WordPress MU: RSS On A WordPress Page | Richard Bui | Bui4Ever.com6.Knowledge Base7.Come (ma Soprattutto Perch) Implementare un Sideblog - seconda parte Francesco Gavello - Blog Marketing Tips, Web & Blogosfera

    8.

    online backup programs software technical comparison | yon Leveron blog9.Twitter Trackbacks for How to Import and Display RSS Feeds in WordPress Perishable Press [perishablepress.com] on Topsy.com

    10.

    Subscribe to comments on this post

    Share your thoughts..

    Top Read official comment policy

    Name

    Email

    Website

    Comment

    Page 15 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • 55

    66

    Submit Comment

    Subscribe to comments gfedcb Notify me of follow-up comments via email [or] Subscribe to comments on this post via RSS

    Previous post Next post

    4G Series: The Ultimate Referrer Blacklist, Featuring Over 8000 Banned Referrers Best Practices for Error Monitoring

    SubscribeContactSearchAboutArchives

    Subscribe to Perishable Press

    + 2893.13 Subscribers

    Verfiy subscriber countLearn more about feeds

    Subscribe to main contentSubscribe to all commentsSubscribe via email

    Elsewhere..

    Subscribe to my Twitter feedSubscribe to my Tumblr feedSubscribe to my FriendFeed

    Contact Perishable Press

    Contact Jeff via email Contact Jeff via form

    Page 16 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Follow me on TwitterNetwork with me at LinkedInNetwork with me at Facebook

    Elsewhere..

    Perishable @ DeliciousPerishable @ TechnoratiPerishable @ StumbleUpon

    Search Perishable Press

    Type and press enter to search the site..

    About Perishable Press

    Perishable Press is the virtual playground of Jeff Starr visionary, founder and lead developer of Monzilla Media, a small web and graphic

    Read more..

    More About Perishable PressA Closer Look at Perishable PressAbout Perishable Press, First Edition

    Perishable Press Archives

    Archives and Sitemaps..

    Perishable Press ArchivesPerishable Comment ArchivePerishable Category ArchivePerishable Press Tag ArchivePerishable Press XHTML SiteMapPerishable Press XML SiteMap

    Informational Pages..

    Link to Perishable PressFrequently Asked QuestionsPerishable Press ChangeLogAccessibility StatementWelcome to Dungeon!

    JavaScriptXHTMLCSSPHPSQLApache

    Page 17 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Exclusive JavaScript Tutorials

    Compressed JavaScript CompressionUnobtrusive JavaScript Dynamic ClockToggle Element Visibility via JavaScriptNine Ways to Embed Flash with JavaScriptUnobtrusive Auto-Clear and Restore Multiple InputsOpen External Links as Blank Targets via Unobtrusive JavaScript

    JavaScript Tag Archive

    Exclusive (X)HTML Content

    (X)HTML Document Header ResourceEmbed External Content via iframe and divBare-Bones HTML/XHTML Document TemplatesRethinking Structural Design with New Elements in HTML 5Wrapping Your Head around Downlevel Conditional CommentsContent Negotiation for XHTML Documents via PHP and htaccess

    (X)HTML Tag Archive

    CSS Tips, Tricks, and Hacks

    A Killer Collection of Global CSS Reset StylesAbsolute Horizontal and Vertical Centering via CSSLessons Learned Concerning the Clearfix CSS HackPure CSS: Better Image Preloading without JavaScriptMaximum and Minimum Height and Width in Internet ExplorerSharpen Your Site by Removing Unwanted Link Border Outlines

    CSS Tag Archive

    Exclusive PHP Articles

    How to Block IP Addresses with PHPAdvanced PHP Error Handling via PHPEliminate 404 Errors for PHP FunctionsDrop-Dead Easy Random Images via PHP5 Easy Ways to Display Syntax Highlighted PHP CodeContent Negotiation for XHTML Documents via PHP and htaccess

    PHP Tag Archive

    Featured SQL Tutorials

    Fixing Mint after Switching ServersMySQL Magic: Find and Replace DataBackup that Database with phpMyAdminEnable or Disable Comments and Pingbacks via SQLReduce the Size of the WP-ShortStat Database TableRemove Spam from the Comment Subscription Manager

    SQL Tag Archive

    Page 18 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Apache & HTAccess Voodoo

    Stupid htaccess TricksCustom HTTP Errors via htaccessHow to Block Proxy Servers via htaccessAdvanced PHP Error Handling via htaccessUltimate htaccess Blacklist 2 (Compressed Version)Creating the Ultimate htaccess Anti-Hotlinking Strategy

    HTAccess Tag Archive

    WordPressTutorialsBloggingSeries Archive

    Popular WordPress Articles

    Perishable Press WordPress PluginsPerishable Press WordPress Themes6 Ways to Customize WordPress Post OrderPerishable Press Triple Loop for WordPressComprehensive HTAccess Canonicalization for WordPressHow to Display Your Twitter Posts on Your WordPress Blog

    WordPress Tag Archive

    Exclusive Tutorials

    Hacking Firefox ExtensionsHow to Add Meta Noindex to Your FeedsLaunch Multiple Programs with One ClickProtect Your Site Against UserCash and Other ScumbagsBlackBerry Curve as Wireless Bluetooth Modem for OS-X MacInstall Windows 98SE and Windows XP Pro on Sony Vaio PCG-F430

    Tutorials Tag Archive

    Blogging Ideas and Insights

    The Pros and Cons of BloggingFive-Step Feed-Portfolio MakeoverUnicode Character Reference for Bloggers10 Firefox Extensions that I Use Every DayNotes and Tips for Better Social BookmarkingBloggers Toolbox: Strategic Elements for a Perfect About Page

    Blogging Tag Archive

    Exclusive Series Articles

    Blacklist Candidate Series SummaryWordPress Basics Series SummaryThe Perishable Press Dofollow Series

    Page 19 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Series Summary: Building the 3G BlacklistPerishable Press CSS Hackz Series SummarySeries Summary: Obsessive CSS Code FormattingSeries Summary: Minimalist Web Design Showcase

    Perishable on TwitterPerishables Twitter Feed

    Follow Perishable @ Twitter

    Praise the Lord the kids are finally back in school. Six hours of pure silence :)

    Perishable on TumblrPerishables Tumblr Feed

    Join Perishable @ Tumblr

    help me in plain english

    Mon, 31 Aug 2009

    This has got to be the most ironic comment I have ever read:

    hi i dun a stupid noooby mistake and dint think about encrytion i just put a pass in the change pass box and now when i attempt to see my main.php or index.php its sayin password no and error how can i reset back to having no password or were can i edit the bit so that a pass is automattically seen or if not posable how can i make it so i can put in the pass i made at some point so i can login this way? the 3rd is most prefered as this will help me with other projects i am planning as i am a php noob :s plz sum1 hu is clever help me in plain english

    Thanks, jay you made my week with that one.

    Redirection After Registration

    Tue, 04 Aug 2009

    After searching high and low for an unobtrusive method of redirecting users to a custom URL after registering at a WordPress-powered site, I finally resorted to (gasp) hacking the core. I simply could not find a better way of doing it that didnt require a ton of additional code. I found several ways of redirecting users to various URLs after logging in and out, but absolutely nothing seems to exist on redirecting users to, say, the home page, or better yet, back to the current page after registering as a subscriber (or whatever role the Admin has set for new registrations). Indeed, the only way to direct a user to some page other than the default WordPress Registration complete. Please check your e-mail. screen (which looks just like the WP Login page, btw) is to hack the wp-login.php file.

    Thus, for the sake of remembering this technique, helping others, and/or inspiring someone to find a solution, heres how to hack WordPress to change the page that users are directed to after they register (via submission of a username and email address). First, open the wp-login.php file and find the line that says, wp_redirect('wp-login.php?checkemail=registered');. Thats the key right there. To change the location, replace the part that says, wp-login.php?

    Page 20 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • checkemail=registered with the URL to which you would like to direct the newly registered users. You may use full URLs or even relative paths to a specific file. Thats all there is to it. Its still hacking the core, but not by much ;)

    Remember, if youre going to hack the core, make a note of the change(s) and refer to it before/after each subsequent upgrade.

    A 500KB wp_options Table is Too Much

    Thu, 09 Jul 2009

    After my server crashed, I found myself restoring my sites WordPress database. While there, I decided to dig around a bit and make sure everything was up to snuff. While looking through the wp_options table, I was surprised to discover that WordPress seems to cache around 400KB of Planet WordPress dashboard feeds (among other things). Thats a little extreme if you ask me, so I decided to clean things up and reduce my overall database size by around half a megabyte. Heres how I did it using my archaic 2.3 version of WordPress and phpMyAdmin.

    Step One: Take Some Notes

    Before doing anything, copy and paste a few text snippets from your dashboard feeds. This will enable you to easily locate the oversize options fields for removal in Step Three. Note: permalinks from the various feed entries make for good search candidates.

    Step Two: Kill the Feed

    Place this in your themes functions.php file (props to Michael Shadle for the code):

    function remove_dashboard_feeds() { remove_action(admin_head, index_js); } add_action(admin_head, remove_dashboard_feeds, 1);

    Step Three: Clean up Your wp_options Table

    Once that is done, you may clean up your database by doing a quick search for some of the text snippets (permalinks work great) that you copied from the dashboard feeds in Step One. The field(s) that you find should be named something like rss_123abc, where the 123abc is some long, apparently random alphanumeric string. Once you have disabled the feed via functions.php, feel free to reduce the size of your database by deleting the field(s) used to store data for the dashboard feed.

    Doing this saved me an extra ~400KB of space, which is much-needed as the size of my Perishable Press database continues to grow.

    Stop Errors when Running Multiple Themes

    Sat, 30 May 2009

    Another quick WordPress tip for anyone running multiple themes in WordPress. If your site provides users the option of selecting from a number of different themes, you may have noticed errors like this in your PHP error log:

    [28-May-2009 05:46:50] PHP Warning: main(): Failed opening //press/wp-content/themes/requiem/searchform.php for inclusion

    Page 21 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • (include_path=/usr/lib/php:.:/usr/php4/lib/php:/usr/local/php4/lib/php) in //press/wp-content/themes/default/sidebar.php on line 6

    [28-May-2009 05:49:02] PHP Warning: main(//press/wp-content/themes/requiem/searchform.php): failed to open stream: No such file or directory in //press/wp-content/themes/default/sidebar.php on line 6

    These errors happen when a user loads a page using a non-default theme that calls the searchform.php file via the following code:

    Since the template path is based on the default theme, this code will attempt to locate searchform.php in the default themes directory. Thus, non-default themes that contain this code will produce the PHP errors shown above.

    Fortunately, eliminating this problem is as easy as replacing the TEMPLATEPATH with the actual path to the file in your theme. Something like this:

    ..where the (ellipses) represents something like, home/public/domain or similar, depending on your setup. This path must be the absolute path to work properly. Repeat this process as necessary for any other instances of TEMPLATEPATH.

    Thats all there is to it no more pesky PHP errors for missing template files! :)

    Maximum Characters for Google Meta Tags

    Wed, 27 May 2009

    I was going to post this on Twitter, but the service was down or otherwise not responsive (as it frequently is), so I decided to post the information here at Tumblr instead.

    After trying to determine the maximum number of characters allowed for meta title, keywords, and description tags, I realized that the answers are not always clear, even where Google is concerned. One SEO site says one thing, someone in the Google forums says another. Bloggers and designers all seem to have their own opinions.

    Fortunately, many of the proclaimed answers I encountered all seem to converge on a common set of values for the three meta tags. Here are my findings:

    meta title tag: Perhaps the most widely agreed upon max-character value of the bunch, 60 characters (including spaces) seems to be the common denominator for the all-important title tag. Of course, you can make your titles as long as you want, but keep in mind that Google will only display the first 60 characters.

    meta description tag: Lots of disagreement on this one, with some experts claiming a 160-character maximum (including spaces) and others saying that the value is more like 150. The range of values for the description tag ranged from over 200 to around 150, with 160 being a very common value. Thus, to be on the safe side, I recommend meta description tags of no more than 150 characters.

    meta keywords tag: How many keywords can you stuff into the meta keywords tag? Well, that all depends on how many characters each of them contains. Lots of disagreement on this one, with lots of folks pointing out the utter foolishness of even bothering with meta keywords. Oh well, I still use them, and have determined that 800 (including spaces) seems to be a safe number of maximum characters for the meta keywords tag.

    Page 22 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Of course, I am only blogging this info for my own future use, but I like to think of myself as a reliable source of information, so perhaps these max-character values will be useful to you as well. If you would like to chime in on the topic, please do so via Twitter. Any previous comments may be seen by clicking here.

    Read more on Tumblr..

    Subscribe to Comments Recent DialogueKen: For some reason, I can't get this to work in Firefox 3.5.2. Any ideas?...Abbott: Ha! Success. I guess the new version fixed it. Also, I added the readme.txt tweak. Thanks man. I suppose you could delete this exc...

    Abbott: jeff, 1. latest 2.8.4 2. yes, full admin level 10 3. no. i did receive other server errors, because i've applied the 4G. since t...

    National Reporter: I was searching for a tool that would help me to feed articles for me to my website and i found it here and i think its very useful s...

    Jeff Starr: Hi Abbott, I have read many reports of this error happening with WordPress in a variety of scenarios: plugins, upgrading, auto-upgrad...

    Abbott: ColdForm installs and activates no problem, but when I try to access the options/setup page under the settings menu it basically kick...

    Jeff Starr: @Baruch: you're welcome :)...Baruch: Jeff, you are a genius!:)) The script is working flawlessly now! I'm so relieved! Thank you sooo much for taking the time to twe...

    Sebastian: @ HeadY Besten Dank! It works! I am using: mootools/1.2.3/mootools-yui-compressed.js and I took a new 'more' from the mootools ...

    HeadY: @15 ill do this, check if you have the right more version, oder check if it works with the 1.2.2 Core from Google: http://ajax.goog...

    Read more recent comments..

    Subscribe to Content Recent Activity

    Recent Articles

    Tell Google to Not Index Certain Parts of Your PageSexy HTML List TricksThe 5-Minute CSS Mobile MakeoverThe Power of HTML 5 and CSS 3Display Random Posts from Specific Tags or CategoriesHTAccess Password-Protection TricksAnother Boring Personal Update

    Popular Posts

    Wireless Internet: BlackBerry Curve as Bluetooth Modem for OS-X MacCategory LiveBookmarks PlusThe Perishable Press 4G BlacklistWordPress Plugin: Contact ColdformTell the CowsStupid htaccess TricksBlogStats PCC PluginThe htaccess Rules for all WordPress PermalinksImportant Security Fix for WordPress

    Page 23 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Maximum and Minimum Height and Width in Internet Explorer

    Recent Updates

    Wireless Internet: BlackBerry Curve as Bluetooth Modem for OS-X Mac Edited: August 29, 2009

    Tell Google to Not Index Certain Parts of Your Page Edited: August 24, 2009

    Open Casket Edited: August 23, 2009

    Random Articles

    Eight Ways to Blacklist with Apaches mod_rewrite From: February 03, 2009

    Have You Seen Endgame? From: January 30, 2008

    The Deluxe One-Minute Dofollow WordPress Upgrade From: September 10, 2007

    Explore the Archives..

    Validation

    Far from perfect..

    XHTML ValidationCSS ValidationRSS ValidationWCAG ValidationAAA CredentialsAccessibility

    Switch Themes

    Customize the site..

    Bare bonesClassic themeDark minimalismLight minimalismNew minimalismCurrent themeMore themes..

    Perishable Sites

    Business and pleasure..

    Monzilla Mediamindfeed.orgDead Letter Art

    Page 24 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009

  • Networked

    Connected elsewhere..

    9rules NetworkPerishable PressReturn to Top

    Friends

    Through thick and thin..

    DonaceRick BeckmanThane ChampieChris CoyierStephen CroninWill MaccTerry MunLouis PontoiseGraham SmithKim Woodbridge

    Copyright 20052009 Perishable Press All Rights Reserved Full credits Site Design by Monzilla Media

    Page 25 of 25How to Import and Display RSS Feeds in WordPress Perishable Press

    9/4/2009


Recommended