Categories
One Hundred Meats Uncategorized

Bacon vegie burger. #100meat

Categories
Programming Uncategorized WordPress

WordPress Widget – Exclude some categories

I’ve often found a need for a simple replacement to the WordPress category widget that allows me to remove some of the categories. I whipped this up real quick for a client and thought others might find it handy. You can copy and paste it or download it from Google Code. Comment with any questions or suggestions.

 'Selective categories', 'description' => 'Show a list of Categories, with the ability to exclude categories' );
                $control_ops = array( 'id_base' => 'some-cats-widget' );
                $this->WP_Widget( 'some-cats-widget', 'Selective Catagories', $widget_ops, $control_ops );
        }

        function form ( $instance){
                $defaults = array( 'title' => 'Catagories', 'cats' => '' );
                $instance = wp_parse_args( (array) $instance, $defaults );
                ?>
                

"; wp_list_categories("exclude=$cats&title_li="); echo ""; echo $after_widget; } } function register_jorbin_widget(){ register_widget('limited_catagories_list_widget'); } add_action('widgets_init', 'register_jorbin_widget'); ?>
Categories
mostly pointless. Uncategorized

Tweets from the week before 2010-02-22

Categories
One Hundred Meats Uncategorized

Late night DC food options are severly limited. Ended up with some Hooters last night. First time in years. #100meat

Categories
One Hundred Meats Uncategorized

Had my favorite Chili Dog in the world last night, a Chili Half Smoke from Ben’s Chili Bowl #100meat

Categories
One Hundred Meats Uncategorized

Making Schnitzel for my Sarah. #100meat

Categories
mostly pointless. Uncategorized

Tweets from the week before 2010-02-15

  • This year's super bowl commercials were mostly lame, repetitive, and lacking originality. #SerialCommaMonday #
  • Only 9 more hours to submit your #CocktailCamp presentation ideas. Some great ideas in already, but we want YOURS! bit.ly/9Encg9 #
  • @chrishalebarnes What did a new line ever do to you to deserve your scorn? in reply to chrishalebarnes #
  • .@SouthwestAir Why don't you offer to call me back, rather then make me sit on hold listening to your annoying music on a loop? #
  • After sitting on hold for 74 min, here are the ideas I came up with to improve phone based customer service: http://aaron.jorb.in/?p=218 #
  • Eating some fried chicken and hoping the blazers can get themselves back in this game. #100meat #
  • My Friend @andreaarbuckle has some great Debt Zombie Advertisements entered in a contest. Take a look and vote at http://bit.ly/bWezlJ #
  • New on http://aaron.jorb.in : Three Simple Sample #WordPress Shortcodes http://aaron.jorb.in/?p=226 #
  • Damn, moving too slow to get coffee on a day when I could really use it. So Tired I can't even think of a Haiku yet. #
  • Through security with plenty me time to spare. #
  • @fromtherooftops Hurt Locker is one of the best films I saw in the last decade. Feel Better and enjoy. in reply to fromtherooftops #
  • #haikufriday travel edition: Off to see the lady / My wonderful lady out east / Is DC warm yet? #
  • PDX > MCI > BWI #
  • Bus to light rail to plane to plane to bus to train to taxi. All I'm missing on this journey is an air tram, a streetcar, and a boat. #
  • Ray's hell burger. Let's see how good this place is. #100meat #
Categories
One Hundred Meats Uncategorized

Ray’s hell burger. Let’s see how good this place is. #100meat

Categories
Code Programming Uncategorized WordPress

WordPress Shortcodes: A how to by example

I love the WordPress shortcode api. I’m willing to stand on a roof and scream it. It makes so many aspects of developing a WordPress site so much easier. It allows you to add dynamic information to any post, page, and with a single line text widget. How easy you ask? Let’s look at some examples so I can show you just how easy it is to use.

A shortcode for this year

Sometimes you just want to include the year inline and there’s no reason you should have to change the blog posts every time you want to do it. Here’s a quick shortcode for the year.
[php]function show_current_year(){
return date(‘Y’);
}
add_shortcode(‘show_current_year’, ‘show_current_year’);[/php]
Just that easy. As you can see there are a few components to a basic short code. The first is a function that returns what we want the shortcode to return and the second is a call to add_shortcode with the first parameters being what we want the shortcode to be and the second is the function we want that shortcode to call.

A custom links list shortcode

So that last one was pretty easy. Maybe we should try something a little harder, like adding an unordered list of links that uses each links image. This time we also add an attribute to allow us to limit it to a specific category.
[php]
function show_bookmark_image_list($atts){
extract(shortcode_atts(array(
‘catagory_name’ => false
), $atts));
if ( $catagory_name == false )
$bookmarks = get_bookmarks();
else
$bookmarks = get_bookmarks("catagory_name=$catagory_name");
ob_start();
echo "<ul class=’link-image-list’>";
foreach($bookmarks as $bookmark){
echo "<li><a href=’".esc_url($bookmark->link_url) ."’><img src=’".esc_url($bookmark->link_image)."’ /></a></li>";
}
echo "</ul>";
$list = ob_get_clean();
return $list;
}
add_shortcode(‘show_bookmark_image_list’, ‘show_bookmark_image_list’);
[/php]
This time we added an attribute called Catagegory_name that we can then retrieve using the shortcode_atts function that also allows us to set a default incase no attribute is set. We then go through the list of bookmarks that we retrieve and echo out the results. Since we want our shortcode function to return the data, we wrap our echo is an output buffer. I prefer to use output buffers because it allows me to use echo (and makes the code more readable in my opinion), but you can also use string concoction and return the string if you want.

Most Recent Tweet

This was removed in August 2013 since it relied upon a non deprecated twitter api

Using Shortcodes inside Text/html widgets

Text widgets can be simple and are great for creating small blocks of content that you can place any where your theme allows. This simple hack will allow you to use shortcodes inside your text widgets. Just add the following single line to your theme’s functions.php file.
[php]add_filter(‘widget_text’, ‘do_shortcode’);[/php]
If you want to download and use these three simple shortcodes and enable the use of shortcodes in your text widgets, download this file, remove the .txt at the end of the file, upload it to your plugins folder, and activate the simple shortcodes plugin.

Those three simple sample shortcodes for WordPress should give you a bit of a base to create your own. What are your favorite shortcodes? What’s a shortcode that you wish existed? Comment below and let me know. Also let me know if there is any part of my code that you don’t understand, and I’ll try to help you understand it.

UPDATE

I’ve added two more twitter shortcodes. You can also download all of my shortcodes and follow along to the development of them on google code.

Categories
One Hundred Meats Uncategorized

Eating some fried chicken and hoping the blazers can get themselves back in this game. #100meat