[wp-trac] [WordPress Trac] #63261: Menu items incorrectly marked as current when page and taxonomy share the same object_id
WordPress Trac
noreply at wordpress.org
Wed May 21 12:09:02 UTC 2025
#63261: Menu items incorrectly marked as current when page and taxonomy share the
same object_id
-------------------------------------------------+-------------------------
Reporter: nuadagency | Owner: audrasjb
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.9
Component: Menus | Version: 6.7.2
Severity: normal | Resolution:
Keywords: has-patch reporter-feedback needs- | Focuses:
test-info | accessibility
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: has-patch has-test-info needs-testing => has-patch reporter-
feedback needs-test-info
Comment:
== 2nd Reproduction Report
=== Description
❌ This report can't still validate that the issue can be reproduced
[https://core.trac.wordpress.org/ticket/63261#comment:6 with the latest
instructions]
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 136.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty 2.9
- MU Plugins: None activated
- Plugins:
* Test Reports 1.2.0
=== Reproduction Steps
1. Given that we require to have a CPT like WooCommerce products and a
custom taxonomy like product categories I've created both a Testing
Example CPT and a Testing Taxonomy, code below
2. I have also created a little shortcode to show current Taxonomy ID
because the Slug wont show it easily for testing demonstration.
3. Create a Post with certain ID, in my example 15
4. Create a Example Testing Taxonomy inside Example Custom Post Type, with
same ID as Post, in my example 15
5. Create an Example Custom Post, and add the shortcode
`[current_taxonomy_id]` to showcase the Taxonomy ID
6. ❌ Going into each element doesn't cause both elements having current-
menu-item, aria-current="page" as commented in the OP
- Check the screencast for more info
=== Actual Results
1. ❌ Error condition is not occurring.
=== Additional Notes
- According to the reporter, @nuadagency, it was important to have a
custom taxonomy to test this. Check code below in Supplemental Artifacts.
- Waiting for a review of my testing protocol and in case something is
wrong, new testing instructions because I have not been able to reproduce
this for now.
=== Supplemental Artifacts
1. Attaching a new screencast: https://streamable.com/50iydk
2. Test code
{{{
function register_testing_taxonomy() {
$labels = array(
'name' => _x( 'Testings', 'general name' ),
'singular_name' => _x( 'Testing', 'singular name' ),
'search_items' => __( 'Search Testings' ),
'all_items' => __( 'All Testings' ),
'parent_item' => __( 'Parent Testing' ),
'parent_item_colon' => __( 'Parent Testing:' ),
'edit_item' => __( 'Edit Testing' ),
'update_item' => __( 'Update Testing' ),
'add_new_item' => __( 'Add New Testing' ),
'new_item_name' => __( 'New Testing Name' ),
'menu_name' => __( 'Testing' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'testing' ),
);
register_taxonomy( 'testing', array( 'example_post' ), $args );
}
add_action( 'init', 'register_testing_taxonomy' );
function register_example_cpt() {
$labels = array(
'name' => __( 'Example Posts' ),
'singular_name' => __( 'Example Post' ),
'menu_name' => __( 'Example Posts' ),
'name_admin_bar' => __( 'Example Post' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Example Post' ),
'new_item' => __( 'New Example Post' ),
'edit_item' => __( 'Edit Example Post' ),
'view_item' => __( 'View Example Post' ),
'all_items' => __( 'All Example Posts' ),
'search_items' => __( 'Search Example Posts' ),
'parent_item_colon' => __( 'Parent Example Posts:' ),
'not_found' => __( 'No example posts found.'
),
'not_found_in_trash' => __( 'No example posts found in
Trash.' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'example_post' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor',
'author', 'thumbnail', 'excerpt', 'comments' ),
'taxonomies' => array( 'testing' ),
);
register_post_type( 'example_post', $args );
}
add_action( 'init', 'register_example_cpt' );
function show_current_taxonomy_id_shortcode() {
$term = get_queried_object();
if ( $term && isset( $term->taxonomy ) && isset( $term->term_id )
) {
return esc_html( $term->term_id );
} else {
return 'Not a taxonomy page';
}
}
add_shortcode( 'current_taxonomy_id', 'show_current_taxonomy_id_shortcode'
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63261#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list