• Resolved dpurselle

    (@dpurselle)


    When I insert shortcode into a page using a plugin to insert PHP, I am getting a Parse error. The parse error occurs no matter which PHP plugin or WordPress theme is used:

    Code on page:

    [insert_php]
    echo do_shortcode(‘[pdb_list filter=”user_login=’ . $current_user->user_login . ‘”]’);
    [/insert_php]

    Page output:

    Parse error: syntax error, unexpected ‘&’ in /home/content/01/12721101/html/CAG/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 2

    I can resolve the parse error by changing the multi-level quote structure (see below), but this coding does not allow the filtering to work – all users in the database are displayed rather then just the logged in user.

    [insert_php]
    echo do_shortcode(“[pdb_list filter=\”user_login=’.$current_user->user_login.’\”]”);
    [/insert_php]

    I have tried using \” and \’ as a the first level quote and ” ‘ as the next 2 levels, but this does not work either:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING in /home/content/01/12721101/html/CAG/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 2

    The shortcode as originally written works fine when embedded directly into a custom template. Any suggestions for coding using a plugin to insert PHP to avoid having to create a custom template for each new theme I try?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Parse error in shortcode inserted into page’ is closed to new replies.