Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor leahkoerper

    (@leahkoerper)

    Hi StDo,

    I’m sorry you’re having trouble. I suspect your theme is causing the problem here. Was the view switcher working before you tired using the tutorial? Have you tried deactivating other plugins to look for a conflict, or switching to a default theme like Twenty Twelve? If you need help, please read this guide to testing for conflicts.

    If you can isolate this as an issue that’s inherent to The Events Calendar, we’d be happy to look into it further. Unfortunately, we can’t help troubleshoot conflicts here on the free forum. If you do find a conflict, you can try getting in touch with the developer of the theme or plugin and see if they can shed some light on the issue.

    We also have some resources that might be helpful for you in troubleshooting a conflict:

    Themer’s Guide – provides an overview of how to customize the plugin’s frontend appearance.
    Tutorials – useful tips and tricks for changing how the plugin looks and behaves.
    Technical Docs – provides an overview of the classes and functions in each plugin

    Good luck, and thanks for using The Events Calendar!

    ~Leah

    Thread Starter StDo

    (@stdo)

    Hi Leah,

    I copied the code to the functions.php of the WP Twenty Fourteen Theme.
    Same thing happening there.

    Ok, maybe try another Theme: Twenty Thirteen?
    Same thing happening there.

    I just copied the following code and inserted it at the end of the functions.php:

    /**
     * Forcing Categories to display in List View in The Events Calendar
     */
    add_action('parse_query', 'use_list_view_for_categories', 60);
    
    function use_list_view_for_categories($query) {
    	// Run once
    	remove_action('parse_query', 'use_list_view_for_categories', 60);
    
    	// Interfere only for non-ajax Tribe category requests not already destined to be presented by list view
    	if (defined('DOING_AJAX') && DOING_AJAX) return;
    	if (!isset($query->tribe_is_event_category) || !$query->tribe_is_event_category) return;
    	if (tribe_is_view('upcoming')) return;
    
    	// Obtain the query term and get a link to list view for that term
    	$main_tax_query = $query->tax_query->queries[0];
    	$term = get_term_by('slug', $main_tax_query['terms'][0], TribeEvents::TAXONOMY);
    	$link = tribe_get_listview_link($term->term_id);
    
    	// Try to redirect
    	wp_redirect($link);
    	exit();
    }

    Brook

    (@brook-tribe)

    Howdy StDo,

    Thanks for pointing that out. That is indeed how the code snippet works. Basically if you are trying to view the category as anything other than list view you are redirected to list view. I have added some verbiage to the tutorial to address this fact.

    The snippet is a bit of a hack. Unfortunately the way our API is currently designed, there is no better way to go about it that I have found, and I have spend a fair bit of time trying to find one. As a semi solution you might be interested in using a theme override to hide the View As menu when tribe_is_event_category() == true.

    I brought this up to my manager, who is intimately familiar with incoming feature requests and the amount of time our devs have to address them. At the moment it does not seem likely that our API is going to change to accommodate a better way to do this. This tutorial has seen very little traffic, and appears to be wildly unpopular. Unfortunately we have to prioritize some of our more popular feature requests well above this. I hope you can understand. It’s not the answer I wanted to give, but like I said I spent quite a bit of time trying to figure out a better way to do things. To the best of my investigation, it is going to require some rather far reaching changes to our API that just are not likely to happen. 🙁

    – Brook

    Brook

    (@brook-tribe)

    Great news StDo! I just updated this tutorial with a work around. The instructions and snippet have changed significantly, but in the end it lets you specify the default view for categories and other views separately just as you want. Cheers!

    – Brook

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

The topic ‘Display Categories in List View – hack’ is closed to new replies.