Support » Plugin: Content Blocks (Custom Post Widget) » [Plugin: Custom Post Widget] Content Block inserting All-in-One Event data

  • Resolved thinguy


    Content block is working fine putting content into a sidebar.
    But when I go to an Event from ‘All-in-One Event Calendar’ it pulls a duplicate of the event main content into the content block area.
    On other pages the same content block works fine.

    Please let me know what info I can provide, I’m running on a WAMP install for Dev

Viewing 5 replies - 1 through 5 (of 5 total)
  • Having this exact same issue. I can hide it with css but that is a pretty janky solution.

    Same problem … I think it is because Custom Post Widget doesn’t do an actual WP_Query to get the content for the widget. Rather, it retrieves the content and runs it through the filters and shortcodes, trying to mimic what the_content() does. However, some filters are specific to a post type (e.g., the events for All-in-One Event Calendar) and they are getting erroneously applied to the content_block content.

    I have modified function widget in post-widget as shown below and it seems to be working for me in my particular case. ymmv…

    function widget($args, $instance) {
    $custom_post_id = ( $instance['custom_post_id'] != '' ) ? esc_attr($instance['custom_post_id']) : __('Find', 'custom-post-widget');
    // Variables from the widget settings.
    $show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
    $content_post = get_post($custom_post_id);
    $content = $content_post->post_content;

    /* NEW */
    global $post;
    $tmp = $post;
    $args = array(
    'p' => $custom_post_id,
    'post_type' => 'content_block'
    $the_query = new WP_Query( $args );

    echo $before_widget;
    while ( $the_query->have_posts() ) : $the_query->the_post();
    if ($show_custom_post_title) {
    echo $before_title . the_title() . $after_title;
    echo $after_widget;

    $post = $tmp;

    /* END NEW */
    /* OLD */
    $content = apply_filters('the_content', $content);
    echo $before_widget;
    if ( $show_custom_post_title ) {
    echo $before_title . $content_post->post_title . $after_title; // This is the line that displays the title (only if show title is set)
    echo do_shortcode($content); // This is where the actual content of the custom post is being displayed
    echo $after_widget;
    /* END OLD */


    Update … the two lines before /* NEW */ aren’t needed and should be moved into the commented out /* OLD */ block …

    Plugin Author Johan van der Wijk


    This is actually caused by the fact that the All-in-One Event Calendar does not check when to insert the event data.

    You can point the developer of the All-in-One Calendar to this post which describes how to properly use the the_content filter:

    Plugin Author Johan van der Wijk


    The latest version of the Custom Post Widget plugin now has the option to disable apply_filters on the_content which should solve this issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Custom Post Widget] Content Block inserting All-in-One Event data’ is closed to new replies.