Custom Post Types and wp_list_pages…….
-
Hello,
I’ve spent most of the day trying to resolve this issue.. Since i had no luck so far, i decided to post it here…I am using a Custom Post Type called “product”. “Products” is also supposed to be the top level menu element on my website. I managed to set up the post type, and list all the pages of that type using wp_list_pages, but what im struggling with are the permalinks, and current-page classes for menu links.
The menu generated through wp_list_pages is lacking current, parent and ancestor classes for each of the “product” pages.. Aside from that, the permalink format for each page is https://mysite.com/product/name-of-the-product, but the menu links are skipping the “product” bit.
heres some code i used to register the post type:
$args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => true, 'menu_position' => 15, 'supports' => array('title','editor','author','thumbnail','excerpt','comments','page-attributes') ); register_post_type('product',$args);
and listing pages with:
$menu_args2 = array( 'depth' => 2, 'post_type' => 'product', 'show_date' => 0, 'child_of' => 0, 'title_li' => '', 'echo' => 0, 'sort_column' => 'menu_order', 'link_before' => '', 'link_after' => '',); echo wp_list_pages($menu_args2);
Umm.. Help?..
P.
- The topic ‘Custom Post Types and wp_list_pages…….’ is closed to new replies.