• Resolved harveyharveyharvey

    (@harveyharveyharvey)


    Hi Guys n’ Gals,

    I’m new to WordPress and must say that I love it! So much so I’ve stopped development on my own CMS and converting my existing websites!

    The Problem I’m having
    I have the same 2 basic requirements for all my sites that I didn’t expect to find so difficult!

    1. To have a main menu item called ‘News’ (pemalink: /news/) with child items ‘Latest News’ (pemalink: /news/latest-news/) and ‘Newsletters’ (pemalink: /news/newsletters/). Posts permalink should also be like this (/news/latest-news/post-slug)
    2. To create news posts in a Custom Post Type so i can separate them from other posts in the Admin interface

    Shouldn’t be too hard should it?

    So i’ve created the Custom Post Type and Tax as follows

    [ Moderator note: please wrap code in backticks or use the code button. ]

    register_post_type(
    		'post-news',
    		array(
    			'labels' => array(
    				'name' => __( 'News' ),
    			),
    			'public' => true,
    			'has_archive' => true,
    			'capability_type'	=>	'post',
    			'supports' => array('title','editor','revisions','thumbnail','excerpt')
    		)
    	);
    	register_taxonomy(
    		'tax-news',
    		'post-news',
    		array(
    			'label' => __( 'News Categories' ),
    			'rewrite' => array( 'slug' => 'news'),
    			'hierarchical' => true,
    			'show_ui'           => true,
    			'show_admin_column' => true,
    			'capabilities' => array('assign_terms')
    		)
    	);

    Then set-up custom permalinks like this

    /%category%/%postname%/

    now i want to set-up the menu in Appearance > Menus

    Ahh… i can’t add the root taxonomy OR the custom page type to create the parent ‘News’ item on the menu. So here lies the problem.

    Attempt 1,628
    i know i’ll create a page template for the parent item. But it has to have a different slug to ‘news’, as news is already taken, so i can’t have my permalinks how i want them. hmm

    Attempt 3,440
    i know i’ll find a plugin that lets me add my custom post type archive to the menu. Custom Post Type’s Archive in WP Nav Menu.

    This is the closest solution. Everything works great (even the menu items stay highlighted when navigating down from main menu item > sub menu item > post).

    BUT the permalinks are as follows:

    Click on News > /custom-post-type-slug/
    Click on Latest News > /custom-taxonomy-slug/term-slug/
    Click on Post > /custom-post-type-slug/post-slug/

    I hope someone can help as i’m tearing my hair out!

    Muchas Gracias!
    Harv

    [No bumping. If it’s that urgent, consider hiring someone.]

Viewing 1 replies (of 1 total)
  • Thread Starter harveyharveyharvey

    (@harveyharveyharvey)

    So thought i’d share what i’ve learned.

    Simple answer is you can’t do what i was trying to do. Custom Taxonomies and Custom Post Types are separate entities and so could not share (or be fudged to appear as if they share) the same slug.

    I was trying to make wordpress hide either the custom post type slug OR the custom taxonomy slug to give the permalink structure i wanted.

    So now i have this set-up

    Custom post type slug = news
    Taxonomy slug = articles

    works a treat and still loving wordpress!

    P.S I still use the “Custom Post Type’s Archive in WP Nav Menu” Plugin so my main menu item “News” displays the post type archive AND is always highlighted when on a term or in a post.

    Hope my experience helps someone else out

    Peas & carrots,
    Harv

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type/Taxonomy navigation and permalinks’ is closed to new replies.