WordPress.org

Ready to get started?Download WordPress

Forums

Event Organiser
[resolved] List event widget isn't showing events on category sidebar (7 posts)

  1. @sefod
    Member
    Posted 1 year ago #

    I have the event's list widget, and shows perfectly on the homepage, but says No Events on category pages.
    Seems like it's using some data from the posts query for the widget too.
    Any idea?

    http://wordpress.org/extend/plugins/event-organiser/

  2. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    That seems odd - are they certainly the same sidebar? (you can have one sidebar for one page, and different for another).

    The query for the events is done here in the source. You could try var_dump($query) to see what the $query array actually holds....

    If that looks ok, then the next step is to check the SQL query. If this is the culprit, it could be another plug-in that is altering the query.

  3. @sefod
    Member
    Posted 1 year ago #

    The sidebar is the same.

    I've tried deactivating all plugins, without success, but changing the theme the widget works fine, so the thing is the theme.

    Also, inspecting a little deeper, at the end of function eo_get_events, i've add this dumps:
    if($query_array){
    var_dump($query_array);
    $events=get_posts($query_array);
    var_dump($events);
    return $events;
    }

    The first ($query_array) is the same for both pages, but the second one($events) is different, so get_posts is acting different for those pages...

    Any ideas?

    Thanks!

  4. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    Seems like the theme is filtering the query on the category pages in such a way that means no posts are returned... (maybe it filters the query to restrict by category on those pages).

    If the template being used is the plug-in provided one then the theme might being doing it in their sidebar template or in functions.php. Which theme is it?

  5. @sefod
    Member
    Posted 1 year ago #

    This is the function that fucked up everything. I've commented by the moment, and it's working OK, but yo know how to fix it in the proper way?
    Thanks!!

    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $post_type = get_query_var('post_type');
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('post','slider','clients','portfolio','nav_menu_item');
        $query->set('post_type',$post_type);
    	return $query;
        }
    }
  6. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    Well its an odd function. I would say the theme author is doing something very wrong. This will filter (almost) every query on category or tag pages. And it seems it is likely to change the post type to 'post' in the query for all queries on that page. Hence you're not getting any 'event' results.

    I wouldn't be surprised if this messed up other post type widgets you might have and depending on how $query->query_vars['suppress_filters'] is set it could even effect the navigation menu.

    In short - the proper way to fix this is probably to comment it out.

  7. @sefod
    Member
    Posted 1 year ago #

    Yes, the theme in general sucks.

    Thanks for the help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic