1

We have a page (wmnf-events.php) with no content that uses a template file (page-wmnf-events.php). The template has 4 different div containers where each container has the same shortcode but for a different category-slug. This page and template have been working as designed for several months and all of a sudden we have this issue.

There is jQuery attached to the page with a dropdown that hides/shows each div according to what you select. All of a sudden, it no longer works and shows the same records for the category slug originally loaded no matter what is selected. I checked the source of the page and find the jQuery is doing its job hiding and showing the appropriate div container, the problem is all the same events for the first category are listed in all 4 div containers. This is what it looks like:

<select id="soflow">
<option value="1">WMNF Events</option>
<option value="2">Community Events</option>
<option value="3">Music Events</option>
<option value="4">Nonprofit Events</option>
</select>
<div id="wmnfevents">
<?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="wmnf-events" limit="20" title="WMNF Events" order_by="start_date,id" pagination="true"]'); ?>
</div>
<div id="communityevents">
<?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="community-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
</div>
<div id="musicevents">
<?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="music-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
</div>
<div id="nonprofitevents">
<?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="nonprofit-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
</div>

When the page loads, all 4 div containers have the same records for the category-slug of wmnf-events. The weird thing is that the page still works on our development site. I have checked the events to ensure they are assigned to the correct categories and verified the same version of WP and all plugins are used on both sites. The only difference between the live site and dev site is basically the HTTPS being used on the live site. Trying to duplicate the issue on the dev site, I created page-test-events.php template along with the test-events.php page and it does the same thing, it has the issue, can't figure out why the original template on the dev site does not have the same issue or how to troubleshoot further. Could someone suggest what my next step could be to determine the cause and/or fix for this problem?

In response to the comment for shortcode callback function, it is a plugin with the shortcode handled by a php class, but this appears to be the function:

public function process_shortcode( $attributes = array() ) {
    // make sure EED_Events_Archive is setup properly
    if ( apply_filters( 'FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE )) {
        EED_Events_Archive::instance()->event_list();
    }
    // merge in any attributes passed via fallback shortcode processor
    $attributes = array_merge( (array)$attributes, (array)$this->_attributes );
    //set default attributes
    $default_espresso_events_shortcode_atts = array(
        'title' => NULL,
        'limit' => 10,
        'css_class' => NULL,
        'show_expired' => FALSE,
        'month' => NULL,
        'category_slug' => NULL,
        'order_by' => 'start_date',
        'sort' => 'ASC',
        'fallback_shortcode_processor' => FALSE
    );
    // allow the defaults to be filtered
    $default_espresso_events_shortcode_atts = apply_filters( 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', $default_espresso_events_shortcode_atts );
    // grab attributes and merge with defaults, then extract
    $attributes = array_merge( $default_espresso_events_shortcode_atts, $attributes );
    // make sure we use the_excerpt()
    add_filter( 'FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true' );
    // apply query filters
    add_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' );
    // run the query
    global $wp_query;
    $wp_query = new EE_Event_List_Query( $attributes );
    // check what template is loaded and load filters accordingly
    EED_Events_Archive::instance()->template_include( 'loop-espresso_events.php' );
    // load our template
    $event_list = EEH_Template::locate_template( 'loop-espresso_events.php', array(), TRUE, TRUE );
    // now reset the query and postdata
    wp_reset_query();
    wp_reset_postdata();
    EED_Events_Archive::remove_all_events_archive_filters();
    // remove query filters
    remove_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' );
    // pull our content from the output buffer and return it
    return $event_list;
}
  • 1
    Please properly format your question, it is a bit mess to properly read it, you totally lost me here. Could someone suggest what my next step could be to determine the cause and/or fix for this problem => Correct your syntaxing, you are using improper/illegal syntaxing here. Close voting as this is a php issue – Pieter Goosen Dec 28 '15 at 18:36
  • A php issue? This only happens when multiple shortcodes are on the page. When using only one instance of the shortcode, the proper records are retrieved for the category slug being used. I'm not sure how shortcodes are a php issue. It seems to be the query is getting reset somehow and I was looking for help to determine how that could happen in WP. Not sure how I can put it differently. Thanks anyway. – Robert Fitzpatrick Dec 28 '15 at 19:15
  • Post the shortcode callback function please. – s_ha_dum Dec 28 '15 at 20:30
  • 1
    @RobertFitzpatrick, it is unreasonable to assume that people here will code review your code when it is so badly formatted or just long, or requires knowledge of internal wordking of plugins. You need to do the debugging to find the root cause by yourself and then you can ask for help with a solution. – Mark Kaplun Dec 29 '15 at 4:14
  • Well yes, you are using incorrect syntax, I cannot see how this can even work once with the syntax you are using in your first block of code. Your code is also really really messy, so it makes debugging hard, and as @MarkKaplun said, expecting someone to work through code this badly formatted and using wrong syntaxing is just unreasonable. There is also to much info missing like classes and methods that is not native to WordPress, so it is impossible to guess how those code looks like and how they behave. You might have better luck contacting the authors or using his support route – Pieter Goosen Dec 29 '15 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.