[resolved] shortcode works OK on Pages, not at all on Posts (3 posts)

  1. Daniel Payne
    Posted 5 years ago #

    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) {
    "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.

  2. Michael
    Forum Moderator
    Posted 5 years ago #

    how is your single.php (and/or index.php) programmed to show the post's content?

    are you using 'the_content()' ?

  3. Daniel Payne
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic