• Resolved Daniel Payne

    (@djepayne)


    I’m an experienced PHP coder and have created a custom theme from scratch and everything is working OK however my shortcode only works on Pages but not on Posts.

    Does anyone have a hint of what I should look at?

    Here’s an example in my functions.php file:

    function show_pmpa_registration($atts, $content = null) {
    extract(shortcode_atts(array(
    "amount" => '89'
    ), $atts));
    global $post;
    $retour = "Hello world";
    return $retour;
    }
    add_shortcode("register_pmpa", "show_pmpa_registration");

    When I add the following shortcode in my Post it does not work and just echoes the shortcode:


    [register_pmpa amount=99.99]

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • how is your single.php (and/or index.php) programmed to show the post’s content?

    are you using ‘the_content()’ ?

    Thread Starter Daniel Payne

    (@djepayne)

    OK, thanks for the hint. I looked in my index.php file and I was using: print get_the_content();

    Changing that back to: the_content();

    made the shortcode work again.

    Thanks for the clue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘shortcode works OK on Pages, not at all on Posts’ is closed to new replies.