Changing Precedence Of Permalinks For Different Post Types?
-
I have a series of Pages with the heirarchy:
/albums
/name1
/name2
/name3If a visitor simply types:
mysite.com/name2
…it will display /albums/name2/
I don’t need to fully express the link as /albums/album2
Now, I also have a heirarchical post_type called ‘songs’ which is not hidden, but would be far less often visited.
/songs/name1
/songs/name2
/songs/name3…etc
At some point WordPress has changed. What I’ve found is that, if I create a -song- with the same slug as a -page- the link will go to the -Song- and not the -Page-. IOW:
If a visitor clicks on a link /name2 it brings them to /songs/name2 NOT what it used to do which was /albums/name2
At some point the custom post type ‘songs’ seems to take precedence so if there is a page with the slug ‘name2’ and a page with the slug ‘name2’, WordPress will redirect to /songs/name2 which is -bad- for me.
In short: How do I make Pages have precedence over Songs when I don’t type in the complete path?
Below is my code for the custom post type. I’ve tried all manner of changes to the rewrite array to no avail.
Suggestions?
TIA
//songs taxonomy add_action( 'init', 'create_songs_post_type' ); function create_songs_post_type() { $labels = array( 'name' => __( 'Songs' ), 'singular_name' => __( 'Song' ) ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => false, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'songs'), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array( 'title', 'post-formats', 'excerpt', 'custom-fields', 'revisions','post-formats' ) ); register_post_type( 'songs', $args); } function songs_init() { // create a new taxonomy register_taxonomy( 'songs_tax', array( 'label' => __( 'Songs_Tax' ), 'sort' => true, 'args' => array( 'orderby' => 'term_order' ) ) ); } add_action( 'init', 'songs_init' );
- The topic ‘Changing Precedence Of Permalinks For Different Post Types?’ is closed to new replies.