Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MT | TEC | Fix for Single Event 404s with attachment set in WP Query
<?php
/*
* Possible solution for Single Event page 404 errors where the WP_Query has an attachment set
* IMPORTANT: Flush permalinks after pasting this code: http://tri.be/support/documentation/troubleshooting-404-errors/
*/
function tribe_attachment_404_fix () {
if (class_exists('TribeEvents')) {
remove_action( 'init', array( TribeEvents::instance(), 'init' ), 10 );
add_action( 'init', array( TribeEvents::instance(), 'init' ), 1 );
}
}
add_action( 'after_setup_theme', 'tribe_attachment_404_fix' );
@incredimike

This comment has been minimized.

Copy link

@incredimike incredimike commented Dec 2, 2017

I think this is incorrect and causes a deprecation warning as of 3.10. Limited testing shows that changing TribeEvents to Tribe__Events__Main seems to fix it. YMMV.

@SleeplessinDC

This comment has been minimized.

Copy link

@SleeplessinDC SleeplessinDC commented Jan 22, 2018

I agree that this snippet is incorrect. I get the following PHP Notice

PHP Notice: /wp-content/plugins/the-events-calendar/src/deprecated/TribeEvents.php is deprecated since version 3.10! Use Tribe__Events__Main instead. in /wp-includes/functions.php on line 3966

@andrasguseo

This comment has been minimized.

Copy link

@andrasguseo andrasguseo commented Jan 23, 2018

Thanks for sharing that info @incredimike. I have forked the snippet and adjusted it. You can find it here:
https://gist.github.com/andrasguseo/b3283cb4503c880a205448dbafc19f7b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment