• Resolved Matt Pramschufer

    (@mattpramschufer)


    In your code on

    mas-static-content/includes/class-mas-static-content-shortcodes.php on line 56 it currently has the following

    echo '<div class="mas-static-content' . esc_attr( $class ) . '">' . apply_filters( 'the_content', $post->post_content ) . '</div>';

    Can that be updated to simply be

    echo '<div class="mas-static-content' . esc_attr( $class ) . '">' . apply_filters( 'widget_block_content', $post->post_content ) . '</div>';

    Or you could change how you get the post_content from being to include the_post(); before you access the_content filter, and then add wp_reset_postdata(); after you output your content to reset the post back to the main query.

    As any plugin that utilizes the_content filter for its traditional uses inside of the loop will have an unexpected outcome when your plugin is enabled.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Kader Ibrahim S

    (@ibndawood)

    Hello @mattpramschufer,

    Thank you for reaching us. MAS Static Content is intended to be used in custom loop and outputs the post content at a given place. Are you facing any specific issues using the_content filter? Can you please help me understand the issue that you are facing with examples/screenshots?

    Thread Starter Matt Pramschufer

    (@mattpramschufer)

    I understand your plugin is intended to be used in a custom loop, but you need to make sure you are resetting the main query because you are using get_post() rather than a $wpdb->query

    The reasoning is, other plugins use the_content filter to add or remove content for the active post/page the user is looking at. Since you do not reset the main query in your code, other plugins attempting to use the_content filter will their have the filter ran on posts that it is not intended to be ran on.

    Plugin Contributor Kader Ibrahim S

    (@ibndawood)

    Hello @mattpramschufer

    My sincere apologies for not responding earlier. We now have a dedicated support staff to answer all support requests in our www.remarpro.com support forums.

    Regarding your suggestions, I appreciate it. I’ve made these changes to the repository here: https://github.com/madrasthemes/mas-static-content/blob/master/includes/class-mas-static-content-shortcodes.php#L50-L78 Can you please check and let me know if this is okay?

    Once again I thank you for your wonderful inputs.

    Kindest Regards,
    Ibrahim

    Thread Starter Matt Pramschufer

    (@mattpramschufer)

    Awesome, looks good to me!

    Plugin Contributor Kader Ibrahim S

    (@ibndawood)

    Thank you @mattpramschufer. We’ll release this as an update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Use of the_content filter outside of loop’ is closed to new replies.