Support » Plugin: Shortcode Exec PHP » [Plugin: Shortcode Exec PHP] Last five posts code is broken with this update

  • This code works with version 1.17:

    // Prevent recursion
    global $outerPost;
    if ($outerPost) return "";
    // Parse parameters
    extract(shortcode_atts(array('query' => ''), $atts));
    $query = html_entity_decode($query);
    // Create new post loop
    global $post;
    $outerPost = $post;
    $my_query = new WP_Query($query);
    while ($my_query->have_posts()) {
    	// Process post
    	echo '<li><em><a href="'; the_permalink(); echo '">'; the_title();
    	echo '</a></em><br/>';
    $post = $outerPost;
    $id = $post->ID;
    $result = ob_get_contents();
    return $result;

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor M66B


    I just tested this code with the latest version (1.20) and it works, but maybe the shortcode is not executed in your specific case.

    Can you please tell me more details about the problem, like your WordPress version, where you use the shortcode (post, page, widget, comment, etc), what attributes you use (the query parameter), if the shortcode is replace by an empty string or an error message or if the shortcode isn’t replaced but a question mark is appended. Are you using the latest version of Shortcode Exec PHP?

    You could try adding the following unset statement:

    $post = $outerPost;
    $id = $post->ID;

    Please let me know if your problem is solved (in whatever way).

    I just updated to version 1.20 of the plugin on WordPress 3.0.4 and the code still doesn’t work. I’m using the following shortcode inside of a page: [last_five query=”showposts=5″]

    It’s displayed as: [last_five]?

    I added the code you suggested and it’s still not working. Here’s the page that’s having the problem:

    Click on the “Technology Blog” tab on the right.

    I just reverted back to version 1.17 of the plugin and it is now working.

    Plugin Contributor M66B


    The question mark following the shortcode as displayed means the post or page author is not allowed to execute shortcodes. This is a new feature since version 1.18.

    Could you please take a look at the plugin settings “Required capability for authors to execute shortcodes”. If it is different from ‘edit_posts’, please let me know. Try changing to ‘edit_posts’ and if this still doesn’t work try changing to ‘read’. Please let me know your findings, so I can find out what went wrong.

    How did you upgrade the plugin: from the upgrade menu or on the plugins page?

    OK, this is strange. I did the following:

    1. Deactivated version 1.20
    2. Deleted the plugin
    3. Uploaded version 1.17
    4. Confirmed that it started working again
    5. Performed automatic upgrade to version 1.20
    6. It is now working again

    I checked the “Required capability” and it was set to “edit_posts”. Seems like this might be related to the automatic upgrade process but not sure. I didn’t change anything else – just removed, reverted to old version, then upgraded.

    Plugin Contributor M66B


    Okay, thanks for your response.

    The plugin was probably not properly deactivated and reactivated during the upgrade process. I just released version 1.21 to prevent problems like yours if this happens.

    Sounds good – thanks for your help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Shortcode Exec PHP] Last five posts code is broken with this update’ is closed to new replies.