Connect with us

Tips & Tricks

Turn your RSS feed into a shortcode

Published

on

Last week I wrote how to “Use WordPress to print a RSS feed for Eventbrite attendees“. It was pretty popular, but then I found myself in a place that was more annoying. Trying to incorporate that into a blog post or page.

Without having to download a plugin that will allow PHP to be executed inside a post, I would have to create a template file and use that. Which is what I did, and it works just fine. But for some reason I forgot all about shortcodes! With a shortcode, I could generate all the PHP in the functions file and then just call the shortcode when/where I want.

Okay, so lets show the completed PHP code:

function attendee_feed_print_2009() {
 global $wpdb;
 include_once( ABSPATH . WPINC . '/rss.php' );
 $rss = fetch_rss( 'http://www.eventbrite.com/rss/event_list_attendees/384870157' );
 $items = array_slice( $rss->items, 0 );
 if ( empty( $items ) ) echo '<ul style="list-style-type: none; list-style-image: none; list-style-position: outside;"><li>No items</li></ul>';

 else

 foreach ( $items as $item ) : ?>
 <ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-bottom: 0px">
 <li><!--<strong><?php echo $item[ 'title' ]; //User name ?></strong><br />-->

 <?php echo $item[ 'content' ][ 'encoded' ]; ?>

 <hr style="border: 1px solid #ddd; margin-bottom: 8px" />
 </li>
 </ul>
 <?php endforeach;
}

Now, this code has to be changed for it to work as a shortcode. We’ll have to return the function and not print/echo it.

I also wanted to be able to use multiple instances of the code with different feeds. To do so I had to create a argument to extract from the completed short code. I found a demo at: Alex Mansfield’s post.

Remember this:

function attendee_feed_print_2009() {
 global $wpdb;
 include_once( ABSPATH . WPINC . '/rss.php' );
 $rss = fetch_rss( 'http://www.eventbrite.com/rss/event_list_attendees/384870157' );

We are going to update it to read as follows ( changes in bold ) :

function attendee_feed_print_2009( $rss_nbr ) {
 global $wpdb;
 extract( shortcode_atts( array( 'rss' => ''), $rss_nbr ) );
 include_once( ABSPATH . WPINC . '/rss.php' );
 $rss = fetch_rss( $rss );

And the final code with the fields updated to return the arguments ( put into your functions.php file ( in between <?php ?> ) ) :

function attendee_feed_print_2009( $rss_nbr ) {
  global $wpdb;
  extract( shortcode_atts( array( 'rss' => ''), $rss_nbr ) );
  include_once( ABSPATH . WPINC . '/rss.php' );
  $rss = fetch_rss( $rss );
  $items = array_slice( $rss->items, 0 );
  
  $rss_html = '<div id="eventbrite-attendee-list" style="clear:both;">';
  
  if ( empty( $items ) ) $rss_html .= '<ul style="list-style:none;"><li>No attendees, yet.</li></ul>';

  else

  foreach ( $items as $item ) :

  $rss_html .= '<ul style="background:none; list-style:none; margin:0px">';
  $rss_html .= '<li style="background:none; list-style:none;">';
  $rss_html .= $item[ 'content' ][ 'encoded' ];
    
  $rss_html .= '<hr style="border: 1px solid #ddd; margin-bottom: 10px" />';
  $rss_html .= '</li>';
  $rss_html .= '</ul>';
  
  endforeach;

  $rss_html .= '</div>';

  return $rss_html;
  }

And lets not forget to add the shortcode function!

add_shortcode( 'eventbrite-attendees', 'attendee_feed_print_2009' );

Final outcome with look like this `[eventbrite-attendees rss="http://your-rss-feed.com/"]`

I’ve created this into a plugin!

Download the plugin: http://wordpress.org/extend/plugins/eventbrite-attendees-shortcode/

Plugins

Add the twittar plugin for WordPress w/ comment threading

Published

on

I talked about the Twittar plugin in a previous post. But learned that the read me text file was only useful for installing the necessary php code into WordPress themes that don’t have comment threading enabled.

Since most new themes past version 2.7, pull the comments section from functions.php file, that is where you have to edit the avatars in order to show the twittar settings.

First open you functions.php, and look for a line of code that says:

function custom_comment()

This is where your new comments are pulled from when you have the threaded comments enabled.

Now just find <?php echo get_avatar( $comment, $args['avatar_size'] ); ?> & replace with <?php twittar(70, "", "", "avatar avatar-70 photo", 1, "R"); ?>. Keep in mind that you will need to edit the Twittar setting to fit your site.

Continue Reading

Tips & Tricks

Styling your ordered & unordered list items into 2 columns

Published

on

In a previous post I showed you how to create a custom widget, then I showed you how to create a widget for your monthly archives, and limit the month’s that show. I am showing the past 4 months in my widget at this time.

One of my readers: Alex asked:

How did you make the archives widget to show the dates separately into two columns?

Now I will show you a CSS trick to create this effect:

First we will give the unordered list a width of 100%:

ul#archives {
	width:110%;
	}

Then we will style the <li> nested inside.

ul#archives li {
	display:inline;
	float:left;
	width:120px;
	}

And that is it. Please make sure that you clear the float after your closing </ul>.

Continue Reading

Tips & Tricks

Changing your feedbuner form to work with Google

Published

on

A lot of you may be using a email form to gather email’s via Feedburner. I am use that by now you know Google has decided to dump feedburner.com and move all feeds through Google Proxy or Feeburner2 which is a Google Server. Here is the new form you will need to put on your site to get new email address’s:

<form action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" 
onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=YOUR_FEED_NAME', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">
    <p class="form-label">Enter your email address:</p><p><input type="text" style="width:140px" name="email"/></p>
    <input type="hidden" value="YOUR_FEED_NAME" name="url"/>
    <input type="hidden" value="<?php bloginfo('name') ?>" name="title"/>
    <input type="hidden" name="loc" value="en_US"/>
    <input id="submit" type="submit" value="Subscribe" />
</form>

That’s it, just be sure to change YOUR_FEED_NAME to your feed name. For example, my feed is now http://feeds2.feedburner.com/WPCult. Where WPCult is now my ID.

Continue Reading

Random Search Terms

Title

Recent Posts: Fully Net Worth . com

FaZe Jarvis Net Worth: How Rich is FaZe Jarvis Actually?

FaZe Jarvis Net Worth: How Rich is FaZe Jarvis Actually?

FaZe Jarvis is an English Fortnite player. He is the brother of popular YouTuber FaZe Kay of the Call of Duty gaming group FaZe Clan. As of 2019, FaZe Jarvis net worth is estimated to be $600,000. FaZe Jarvis was born on November 11, 2001, in England. He is more of a new streamer. He […]

Jessica Nigri Net Worth – Hot Gossip and info

Jessica Nigri Net Worth – Hot Gossip and info

Jessica Nigri Net Worth Although she was brought up in New Zealand, Jessica Nigri is from America and she is a cosplay celebrity, voice actress, social media personality, and model. She has a net worth of close to $15. Million. Jessica was born in the U.S. state of Nevada in Reno in August of 1989. […]

Awkwafina Net Worth, Bio, Wiki

Awkwafina Net Worth, Bio, Wiki

Awkwafina net worth Awkwafina is an American artist; She is a comedian, TV personality, actress, and a rapper. Her net worth is $4 million. She was born as Nora Lum in New York City and grew up in Forest Hills, Queens, area of the city. When she was in high school, she played trumpet and […]

True Geordie Net Worth: How Rich the English Podcaster Actually?

True Geordie Net Worth: How Rich the English Podcaster Actually?

Brian Davis, who is better known online as True Geordie, is a British Youtuber. He is best known for his podcast called the True Geordie Podcast along with editor Laurence McKenna where their focus is on interviewing with different Youtubers and Influencers. His channel has a total of 1.7 million subscribers. As of 2019, True […]

Trending