WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Permalink Issue (6 posts)

  1. flashpunk
    Member
    Posted 3 years ago #

    I have 2 custom post types on a development blog i'm working on, one of them seems to be working fine, single entry pages, archives, etc.
    However, the 2nd one lists fine on taxonomy archive pages, however, any permalinks to single entry pages result in a 404 error page. This is in the front end, and also through the admin write panel when clicking on "View Page".

    This is my function.php file showing the initialization of the custom post type. Any help would be very appreciated.

    Thank you!

    function post_type_musicians() {
    	register_post_type(
    		'music',
    		array(
    			'label' => __('Musicians'),
    			'singular_label' => __('musician'),
    			'public' => true,
    			'show_ui' => true, // UI in admin panel
    			'_builtin' => false, // It's a custom post type, not built in!
    			'_edit_link' => 'post.php?post=%d',
    			'capability_type' => 'post',
    			'hierarchical' => false,
    			'rewrite' => array("slug" => "musician"), // Permalinks format
    			'publicly_queryable' => true,
    			'query_var' => true,
    			'can_export' => true,
    			'menu_position' => 5,
    			'supports' => array('title','author','thumbnail','custom-fields','comments','revisions','editor','excerpt')
    		)
    	);
    
            register_taxonomy( 'albums', 'music',
    		array(
                 'hierarchical' => true,
    			 'label' => __('Music'),
    			 'query_var' => 'music',
    			 'rewrite' => array('slug' => 'music' )
    		)
    	);
    }
    add_action('init', 'post_type_musicians');
  2. flashpunk
    Member
    Posted 3 years ago #

    Anyone? I'm really needing help with this!!

  3. flashpunk
    Member
    Posted 3 years ago #

    Please anyone?!

  4. nalins
    Member
    Posted 3 years ago #

    I'm experiencing something very similar to this and haven't been able to find a solution for quite some time now. Can anyone help out?

    Thanks for your time!

  5. Chris
    Member
    Posted 3 years ago #

    You're doing something a little more difficult and complicated than what I was doing - I was having the issue where I'd add custom taxonomies, but the archive pages for the tags in those taxonomies would return a 404.

    I fixed this by "flushing the permalinks": just going to Settings/Permalinks and clicking "Save Changes" without making any changes. I learned about that here:

    http://seanbehan.com/programming/how-to-flush-your-permalink-structure-in-wordpress-when-using-taxonomies-or-wordpress-taxonomies-not-working-instead-i-see-a-404-page/

    Sorry if this doesn't fix your problem - it sounded slightly similar to mine, so I figured I'd post this.

  6. flashpunk
    Member
    Posted 3 years ago #

    This has been resolved. User error on my part, turns out that this section (below), doesn't like when values are the same. In my case 'Music' was causing an issue.

    register_taxonomy( 'albums', 'music',
    		array(
                 'hierarchical' => true,
    			 'label' => __('Music'),
    			 'query_var' => 'music',
    			 'rewrite' => array('slug' => 'music' )
    		)
    	);

Topic Closed

This topic has been closed to new replies.

About this Topic