WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to convert this shortcode.


To ouput like this one (html form)

<ul class="one">
share|improve this question
Just do it. There is nothing stopping you. – toscho Sep 9 '13 at 10:17
Have you read the shortcode api documentation? If so, can you post the code you have tried to implement? Also, whhich type of data will be a, b, c...:words, phrases, html,...? – cybmeta Sep 9 '13 at 10:21
@toscho can we add shortcode parameter to change the <ul class="private"> private to anything [private='public'].Here public will be the new ul class.and my code add_shortcode( 'private', 'shortcode' ); function shortcode( $atts, $content = null ) { $return_string .= '<ul class="private">' . $content . '</ul>'; return $return_string; } – ashraf Sep 10 '13 at 6:37
@ashraf Update your question with more details. Explain exactly where you got stuck. Do not hide important information in comments. – toscho Sep 10 '13 at 7:19
@toscho .The shortcode creates an ul class "private".I want to make this class dynamic.If i write [private='public']then I want to change the ul class to public that is <ul class="private">.. – ashraf Sep 10 '13 at 14:35

First off, your shortcodes are not formatted correctly for WordPress.

You need to have a tag for your shortcode and then define the attributes separately.

Instead of [list-style="one"][/list-style] it needs to be something like [list class="one"][/list]

The following code will add two shortcodes to your WordPress install. [list] and [li]

// shortcode for the list
function LIST_shortcode( $atts, $content ) {

    // get the options defined for this shortcode
    extract( shortcode_atts( array(
        'class'     => '',
        'id'        => '',
        'type'      => 'ul'
    ), $atts ) );

    // output a list and do_shortcode for <li> elements
    return '<' . $type . ' class="' . $class . '" id="' . $id . '">' . do_shortcode( $content ) . '</' . $type . '>';
add_shortcode( 'list', 'LIST_shortcode' );

// shortcode for the list items
function LI_shortcode( $atts, $content ) {

    // get the options defined for this shortcode
    extract( shortcode_atts( array(
        'class'     => '',
        'id'        => '',
    ), $atts ) );

    // return list element
    return '<li class="' . $class . '" id="' . $id . '">' . do_shortcode( $content ) . '</li>';
add_shortcode( 'li', 'LI_shortcode' );

You would then use these like so:

[list class="one"][li]A[/li][li]B[/li][li]C[/li][li]D[/li][/list]

My code also allows you to also..

Define an ID attribute: [list id="someid"]

Define the list type: [list type="ol"]

For this code to work, add it to your theme's functions.php file or create a plugin out of it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.