Im making a custom shortcode for my wordpress site and im just running through the example from the shortcode api for wordpress:

function myshortcode() {

$atts = shortcode_atts(
        'custom_title' => 'Your Title',
        'custom_message' => 'Your Message',
    ), $atts);

    return 'Test: ' . $atts['custom_title'] . ' ' . $atts['custom_message'];



The shortcode in my blog post is:

[my-short custom_title="Test" custom_message="123 Roman Ridge"]

but it outputs

Test: Your Title Your Message

there is nothing else in my blog post except the shortcode, any suggestions?


Note the following line in your function defintion:

function myshortcode() {

it's missing the input parameters $atts and $content so that's why you only get the default attribute values.

Replace it with:

function myshortcode( $atts = [], $content = '' ) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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