[wp-trac] [WordPress Trac] #56154: pre_get_posts fix to show menu on CPT Archives broken in 6.0
WordPress Trac
noreply at wordpress.org
Tue Jul 5 20:21:23 UTC 2022
#56154: pre_get_posts fix to show menu on CPT Archives broken in 6.0
------------------------------+-----------------------------
Reporter: joshpaynedesigns | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 6.0
Severity: normal | Keywords:
Focuses: |
------------------------------+-----------------------------
Before WP 6.0 we have had to add this pre_get_posts fix to show the
wp_nav_menu on custom post type archive and taxonomy pages:
https://casabona.org/2015/03/fix-wp_nav_menu-custom-type-archives-
wordpress/
{{{
function fix_nav_menu( $query ) {
if ( $query->get( 'post_type' ) === 'nav_menu_item' ) {
$query->set( 'tax_query', '' );
$query->set( 'meta_key', '' );
$query->set( 'orderby', '' );
}
}
add_action( 'pre_get_posts', 'fix_nav_menu' );
}}}
Here is an example of the menu not showing on the CPT taxonomy page:
https://www.sbcv.org/video-category/resource-video/
There is a bug in 6.0 that when this is in the functions.php file the WP
menu adds every menu item and other wp nav menus to each wp nav on both
the backend in the menu editor and the frontend of the site. Makes for a
very large menu anywhere a wp menu is called.
Example of the broken menu: https://acbase.wpengine.com/
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56154>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list