I want to convert this shortcode.


To ouput like this one (html form)

<ul class="one">

closed as unclear what you're asking by cjbj, Dave Romsey, fuxia Oct 6 '16 at 9:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    Just do it. There is nothing stopping you. – fuxia Sep 9 '13 at 10:17
  • 3
    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. – fuxia 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.

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