I have a test WordPress site called Cityscape, I figured that I could use a shortcode to generate the code for an entry for each business in the community and the following documents the code for that shortcode that I created to do this. I found an article on Net Tuts that covered WordPress Shortcodes called WordPress Shortcodes – The Right Way

You would call the shortcode by putting this code into a Post entry (one per business in the community), for example:

[newbiz name="wendys" src=""]

and this would generate a Post entry like this:

clicking on the image will take you to the company’s web site or an infomation page about the company if they do not have a web site.

Create the following code in functions.php:

// [newbiz name="dummy", url=""]
function newbiz( $atts ) {
	extract( shortcode_atts( array(
		"name" => '',
		"url"  => '',
	), $atts ) );

	return '
        <div class="box1">
           <a href="'.$url.'">
           <img src="'.$name.'.jpg" alt="" title="'.$name.'" width="152" height="125" /></a> 
add_shortcode( 'newbiz', 'newbiz' );

The following code is generated by the shortcode:

<div class="box1">
   <a href="">
   <img src="" 
      alt ="" title="wendys" width="152" height="125" /></a>
This entry was posted in Design. Bookmark the permalink.