• Resolved milan.latinovic

    (@milanlatinovic)


    Good day,

    We installed Nelio plugin in order to do some A/B testing, but we haven’t been able to use it. After contacting their support and some talking about issue, they narrowed it down to issue with Event Calendar plugin, and ask us to contact you about it.

    After turning of Event Calendar , Nelio works fine and vice versa. So it’s compatibility issue with these 2 plugins.

    I’ll try to explain issue the best I can. If we try to execute the following WP_Query:

    $args = array( ‘post_type’ => ‘tribe_events’ );
    $events = new WP_Query( $args );
    if ( $events->have_posts() ) :
    while ( $events->have_posts() ) :
    $events->the_post();
    the_title()
    endwhile;
    wp_reset_postdata();
    endif;

    it doesn’t work; nothing is returned. Seems like issues like this one were already present and marked resolved, link: https://wordpress.org/support/topic/query-events-with-wp_query-not-working?replies=2

    So, we could name this issue: WP_Query doesn’t work (at least) during an AJAX call.

    Please, let us know if you can include how to handle this issue further?

    All best,

    https://wordpress.org/plugins/the-events-calendar/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Clifford Paulick

    (@cliffpaulick)

    Hi Techno Freak (cool name).

    Thanks for bringing this to our attention.

    Are you referring to https://wordpress.org/plugins/nelio-ab-testing/ ?

    And please explain how I might be able to recreate this issue on my own testing site — what links you’re at, what buttons you clicked, etc — so we can investigate further.

    Thank you.

    Thread Starter milan.latinovic

    (@milanlatinovic)

    Hi Clifford,

    Thank you very much, and yes we’re referring to Nelio-ab-testing plugin 🙂

    Ok, so issue was recognized by me, but bug is recognized by Nelio plugin developers, and they asked us to do some testing on our web site.

    I’m not able to tell you details how to recreate this issue (as end user my only perception is these two plugins are in some kind of collision).

    I have an idea, I would like to connect you with Nelio support (I would send introduction email to everyone, and explain what we’re trying to solve). From that point you can continue talking about issue with them, and if you want to test something you could use our web site (even better, I could create staging web site with same infrastructure, so you can play with it).

    What do you think about this? Personally I like Event Calendar plugin and I would really like to see this trough. 🙂

    All best,

    Brook

    (@brook-tribe)

    Howdy Milan,

    Thanks you for taking the time to share this. We have definitely worked directly with countless plugin and theme devs, but I’m afraid we’re not quite able to that just yet here.

    The code you’ve shared could certainly have issues when run alongside our plugin. Are you saying that the code works fine with Nelio disabled ? Have you tried skipping building your own WP_Query and instead using tribe_get_events() ? What happens if you alter the priority of the query? Run it outside of an ajax query?

    At this point it seems like the main thing this needs is for you or your developer to play around with it and get it working when both plugins are active. Assuming the plugins work fine together when this code is not present, then the unfortunate truth is there is not much we will be able to do working directly with Nelio. Running queries inside of existing queries, like Ajax one, is often error prone and can require a lot of tinkering to get right. Sadly this is just the nature of WordPress.

    Does that all make sense? We’d love to assist as best we can. We are a bit limited on time here in the volunteer forums, but we’ll do what we can.

    Cheers!
    – Brook

    Hi Brook!

    I’m one of the developers behind Nelio A/B Testing. If I run the following code:

    function nelio_tribe_not_working() {
    
    	echo "<h1>tribe_get_events()</h1>\n";
    	$events = tribe_get_events();
    	foreach ( $events as $event ) {
    		echo $event->post_title . "<br>\n";
    	}//end if
    
    	echo "<h1>WP_Query</h1>\n";
    	$args = array(
    		'post_type' => 'tribe_events',
    	);
    	$events = new WP_Query( $args );
    	if ( $events->have_posts() ) {
    
    		while ( $events->have_posts() ) {
    			$events->the_post();
    			the_title();
    		}//end while
    
    		wp_reset_postdata();
    
    	}//end if
    
    	die();
    
    }//end nelio_tribe_not_working()
    add_action( 'init', 'nelio_tribe_not_working' );

    Everything works out of the box. However, if I change WP_Query‘s arguments to the following:

    $args = array(
    	'meta_key'     => '_some_meta_field',
    	'meta_compare' => 'NOT EXISTS',
    	'post_type'    => 'tribe_events',
    );

    then the example does no longer work.

    In this particular case, AJAX is not involved and, yet, things still don’t work.

    Any ideas?

    nicosantos

    (@nicosantos)

    Hey David,

    Thanks for chiming in! I’m not sure about the issue. A dump of the WP_Query will surely help to see why this happens. Maybe there ‘relation’ of the tax query needs to be adjusted?

    Hopefully taking a look at the full query args might lead to the clue of the conflict.

    Best,
    Nico

    Hi @nicosantos.

    The previous example I shared is a minimum working example. Just add the first function in a plugin of your own, or your theme’s functions.php file, along with the add_action statement, and you’ll see things working. If you then change the arguments, things won’t work anymore.

    Could you please test this by yourself and confirm the behavior? You should be able to dump the WP_Query variable and run any further tests you might need to determine what’s amiss.

    Regards,
    David

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Issue with WP_Query causing Nelio plugin not working properly’ is closed to new replies.