• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

WP Shortcodes


S

Sean Lee-Amies

Guest
#1
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!
 
#3
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.
 
T

Tony Hardy

Guest
#4
Yeah as a rule, I find shortcodes too restrictive too. I wouldn't recommend using them for too much.
 
S

Sean Lee-Amies

Guest
#5
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 :)