Last active
January 23, 2018 21:00
-
-
Save elimn/877bc90421526d22900b to your computer and use it in GitHub Desktop.
MT | TEC | Fix for Single Event 404s with attachment set in WP Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
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
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
I think this is incorrect and causes a deprecation warning as of 3.10. Limited testing shows that changing
TribeEvents
toTribe__Events__Main
seems to fix it. YMMV.