4 Updated the info on the default shortcodes.
source | link

A shortcode is a string in square brackets that will be replaced by a callback function.

There are fourseven built-in shortcodes in WordPress: [audio], [video], [playlist], [embed], [wp_caption], [caption] and [gallery].

A shortcode can be registered with:

add_shortcode( 'shortcode_name', 'callback_function' );

The callback must return a string, it must not output anything directly.

Wrong:

function shortcode_callback()
{
    echo 'called';

?>
Hello, I am doing it wrong.
<?php
}

Correct:

function shortcode_callback()
{
    return 'called';
}

The callback function can use three parameters.

Example

A shortcode was used in a post like this:

[sample color="red" tag="div"]Some text.[/sample]

The callback can use the information from this shortcode like this

function shortcode_callback( $args, $content = '', $shortcode_name = '' )
{
    $output = '<' . $args['tag'] . ' style="color:' . $args['color'] . '">' 
        . 'The shortcode ' . $shortcode_name . ' was called.<br>'
        . $content
        . '</' . $args['tag'] . '>';

    return $output;
}

See also the Codex: Shortcode API.

A shortcode is a string in square brackets that will be replaced by a callback function.

There are four built-in shortcodes in WordPress: [embed], [wp_caption], [caption] and [gallery].

A shortcode can be registered with:

add_shortcode( 'shortcode_name', 'callback_function' );

The callback must return a string, it must not output anything directly.

Wrong:

function shortcode_callback()
{
    echo 'called';

?>
Hello, I am doing it wrong.
<?php
}

Correct:

function shortcode_callback()
{
    return 'called';
}

The callback function can use three parameters.

Example

A shortcode was used in a post like this:

[sample color="red" tag="div"]Some text.[/sample]

The callback can use the information from this shortcode like this

function shortcode_callback( $args, $content = '', $shortcode_name = '' )
{
    $output = '<' . $args['tag'] . ' style="color:' . $args['color'] . '">' 
        . 'The shortcode ' . $shortcode_name . ' was called.<br>'
        . $content
        . '</' . $args['tag'] . '>';

    return $output;
}

See also the Codex: Shortcode API.

A shortcode is a string in square brackets that will be replaced by a callback function.

There are seven built-in shortcodes in WordPress: [audio], [video], [playlist], [embed], [wp_caption], [caption] and [gallery].

A shortcode can be registered with:

add_shortcode( 'shortcode_name', 'callback_function' );

The callback must return a string, it must not output anything directly.

Wrong:

function shortcode_callback()
{
    echo 'called';

?>
Hello, I am doing it wrong.
<?php
}

Correct:

function shortcode_callback()
{
    return 'called';
}

The callback function can use three parameters.

Example

A shortcode was used in a post like this:

[sample color="red" tag="div"]Some text.[/sample]

The callback can use the information from this shortcode like this

function shortcode_callback( $args, $content = '', $shortcode_name = '' )
{
    $output = '<' . $args['tag'] . ' style="color:' . $args['color'] . '">' 
        . 'The shortcode ' . $shortcode_name . ' was called.<br>'
        . $content
        . '</' . $args['tag'] . '>';

    return $output;
}

See also the Codex: Shortcode API.

3 added 834 characters in body
source | link

A shortcodeshortcode is a WordPress-specific codestring in square brackets that lets you do nifty things with very little effortwill be replaced by a callback function. Shortcodes

There are four built-in shortcodes in WordPress: [embed], [wp_caption], [caption] and [gallery].

A shortcode can embed files or create objects that would normally require lots of complicatedbe registered with:

add_shortcode( 'shortcode_name', 'callback_function' );

The callback must return a string, ugly code in just one lineit must not output anything directly. Shortcode = shortcut

Wrong:

function shortcode_callback()
{
    echo 'called';

?>
Hello, I am doing it wrong.
<?php
}

Correct:

function shortcode_callback()
{
    return 'called';
}

The callback function can use three parameters.

Example

A shortcode was used in a post like this:

[sample color="red" tag="div"]Some text.[/sample]

The callback can use the information from this shortcode like this

function shortcode_callback( $args, $content = '', $shortcode_name = '' )
{
    $output = '<' . $args['tag'] . ' style="color:' . $args['color'] . '">' 
        . 'The shortcode ' . $shortcode_name . ' was called.<br>'
        . $content
        . '</' . $args['tag'] . '>';

    return $output;
}

See also the Codex: Shortcode API allows you to defined new macros to embed complex objects not supported by WordPress.

A shortcode is a WordPress-specific code that lets you do nifty things with very little effort. Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line. Shortcode = shortcut.

The Shortcode API allows you to defined new macros to embed complex objects not supported by WordPress.

A shortcode is a string in square brackets that will be replaced by a callback function.

There are four built-in shortcodes in WordPress: [embed], [wp_caption], [caption] and [gallery].

A shortcode can be registered with:

add_shortcode( 'shortcode_name', 'callback_function' );

The callback must return a string, it must not output anything directly.

Wrong:

function shortcode_callback()
{
    echo 'called';

?>
Hello, I am doing it wrong.
<?php
}

Correct:

function shortcode_callback()
{
    return 'called';
}

The callback function can use three parameters.

Example

A shortcode was used in a post like this:

[sample color="red" tag="div"]Some text.[/sample]

The callback can use the information from this shortcode like this

function shortcode_callback( $args, $content = '', $shortcode_name = '' )
{
    $output = '<' . $args['tag'] . ' style="color:' . $args['color'] . '">' 
        . 'The shortcode ' . $shortcode_name . ' was called.<br>'
        . $content
        . '</' . $args['tag'] . '>';

    return $output;
}

See also the Codex: Shortcode API.

2 added 461 characters in body
source | link

A shortcode is a WordPress-specific code that lets you do nifty things with very little effort. Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line. Shortcode = shortcut.

The Shortcode API allows you to defined new macros to embed complex objects not supported by WordPress.

A shortcode is a WordPress-specific code that lets you do nifty things with very little effort. Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line. Shortcode = shortcut.

The Shortcode API allows you to defined new macros to embed complex objects not supported by WordPress.

1
| link