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 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.0.1 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | ui, docs | Cc: |
Description
- Create child theme of one of the wordpress themes (e.g. twentyfifteen).
- 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 ) );
- Add 4 products
- Set "Blog pages show at most" to 3
- Add custom link to CPT archive "/products/" to menu (Pretty Permalinks pls)
- Go to the archive page and flip to second page.
Excepting that this should work without a lot of dark workarounds.
Change History (2)
Note: See
TracTickets for help on using
tickets.
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.