Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#30609 closed defect (bug) (duplicate)

CPT archive with pagination does not set current-menu-parent and current-menu-item after flip

Reported by: beelde's profile beelde Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0.1
Component: Posts, Post Types Keywords:
Focuses: ui, docs Cc:

Description

  1. Create child theme of one of the wordpress themes (e.g. twentyfifteen).
  2. Add following example code to your functions.php:
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }
    
    register_post_type( 'Products',
    		
    	array(
    
    		'labels' => array(
    			'name' => __( 'Products' ),
    			'singular_name' => __( 'Product' )
    		),
    		'public' 		=> true,
    		'has_archive' 	=> true,
    		'supports' 		=> array('title', 'thumbnail', 'author'),
    		'menu_icon'	    => 'dashicons-book-alt',
    		'rewrite'		=> true
    	)
    );
    
  1. Add 4 products
  2. Set "Blog pages show at most" to 3
  3. Add custom link to CPT archive "/products/" to menu (Pretty Permalinks pls)
  4. Go to the archive page and flip to second page.

Excepting that this should work without a lot of dark workarounds.

Change History (2)

#1 @joedolson
10 years ago

  • Focuses accessibility removed

#2 @boonebgorges
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi beelde - Thanks for the report. The reason why the current-menu-item logic is not working is because the menu item you are adding is a simple link - http://example.com/products/ - and from WP's point of view, http://example.com/products/page/2 is not the same thing as http://example.com/products.

The most natural way for this to work would be for WP to introduce native support for menu items that link to post type archives. See #16075.

Note: See TracTickets for help on using tickets.