Member Offer
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WP Shortcodes

Discussion in 'Website Coding & Programming Forum:' started by Sean Lee-Amies, Nov 11, 2013.

  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.
    <ul class="classes here">
    [shortcode]<img src="" />[/shortcode]
    [shortcode]<img src="" />[/shortcode]
    [shortcode]<img src="" />[/shortcode]
    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!
  2. Tony Hardy

    Tony Hardy Guest

  3. glenwheeler

    glenwheeler Senior Member

    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.
  4. Tony Hardy

    Tony Hardy Guest

    Yeah as a rule, I find shortcodes too restrictive too. I wouldn't recommend using them for too much.
  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 :)

Share This Page