• Resolved yitwail

    (@yitwail)


    This is a new solution for an old, closed topic. You can read the discussion here:

    https://www.ads-software.com/support/topic/plugin-custom-post-widget-conflict-wother-plugins-queries-duplicating?replies=11

    Rather than wait for the all in one event calendar developer to fix their code, I created a file named custom-post-widget.php in the child theme directory that looks like this:

    <?php
    global $ai1ec_events_controller;
    
    if ($in_calendar = (get_post_type() == AI1EC_POST_TYPE)) {
    	remove_filter('the_content', array($ai1ec_events_controller, 'event_content'), PHP_INT_MAX - 1);
    }
    if ( !$apply_content_filters ) { // Don't apply the content filter if checkbox selected
    	$content = apply_filters( 'the_content', $content);
    }
    if ($in_calendar) {
    	add_filter('the_content', array($ai1ec_events_controller, 'event_content'), PHP_INT_MAX - 1);
    }
    echo $before_widget;
    if ( $show_custom_post_title ) {
    	echo $before_title . apply_filters( 'widget_title',$content_post->post_title) . $after_title; // This is the line that displays the title (only if show title is set)
    }
    if ( $show_featured_image ) {
    	echo get_the_post_thumbnail( $content_post -> ID );
    }
    echo do_shortcode( $content ); // This is where the actual content of the custom post is being displayed
    echo $after_widget;

    This worked like a charm. ?? A similar solution may work with other plugin conflicts.

    https://www.ads-software.com/plugins/custom-post-widget/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Johan van der Wijk

    (@vanderwijk)

    Thanks for sharing this! Hopefully this will help others too!

    I had the same problems everyone was experiencing in the thread link provided by yitwail above (Duplicated content in all of my widgets). When Johan added the ability to check a box for “Do not apply content filters” within the widget window, that fixed my issue of having duplicated content appear in all of my widgets but it removed all of the formatting of my widgets (paragraphs, line breaks, etc.)

    I just fixed my issue by editing line 110 of version 2.5.7 from:

    echo do_shortcode( $content ); // This is where the actual content of the custom post is being displayed

    to:

    echo do_shortcode( wpautop($content) ); // This is where the actual content of the custom post is being displayed

    Thread Starter yitwail

    (@yitwail)

    Johan, thanks for acknowledging my post. ??

    dsburdette, there’s a drawback to doing it your way. You’re modifying the plugin itself, so if you ever update the plugin, you have to modify it again. That’s why I put my changes into a file custom-post-widget.php in the theme folder. You might also want to wpautop($content) only if ( !$apply_content_filters ) is true, in case you have a widget where you don’t want paragraphs & breaks added.

    yitwail-

    Yea, I’m aware I don’t want to edit the plugin directly so thank you for the tip on making the tweak within my theme folder! I’ll get that tidied up right away. Thank you sir.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘workaround for all in one event calendar conflict’ is closed to new replies.