WP Shortcodes

S

Sean Lee-Amies

Guest
So I'm trying to figure out how to write my own shortcode, as I'm having a problem using individual shortcodes as html li tags, it ends up producing two UL's instead of placing the shortcode li's into the one ul.
HTML
<ul class="classes here">
[shortcode]<img src="" />[/shortcode]
[shortcode]<img src="" />[/shortcode]
[shortcode]<img src="" />[/shortcode]
</ul>
PHP
function portfolio_image( $atts, $content = null ) {
return ' <li>
<div class="block_holder"><div class="hover_block block_23">'. do_shortcode($content) .'<div class="circle_over"></div><div class="circle_in"></div><div class="post_info"><a href="#">VIEW IMAGE</a></div></div></div></li>';
}

add_shortcode("portfolio_image", "portfolio_image");

It'd be nice to know how to put the ul into a shortcode as well, but not overly essential. I can't seem to figure it out. Any help would be massively appreciated!
 
Nice post from Tony but I tend to stay away from Shortcodes. They are so restrictive. Without writing out some hardcore functionality you cannot use shortcodes with other classes. If you were using something like SMACSS.
 
Yeah as a rule, I find shortcodes too restrictive too. I wouldn't recommend using them for too much.
 
Yes, indeed. What do you use instead Tony?
I'm just using it to simplify things a little bit. I'm not really relying on it or anything :)
 
Back
Top