WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've recently created several custom post types in a wordpress site, with the code below, they are generating links in the correct form e.g. root/category/id/postname but each link to the full post, pagination or category 404's.

I've tried a number of popular solutions, appending /%category%/%post_id%/ to the url structure, rewriting function names but I'm getting nowhere fast.

With the wordpress permalink structure set to default e.g. root/?page_id=1257 everything works ok.

Any effort to add additional parameters to rewrite (see below) produces "Parse error: syntax error, unexpected ';'" even though no ';' is present.

'rewrite' => array(
'slug' => 'issue')

Any help appreciated - highly confused, very frustrated!


add_action('init', 'mjwpress_register');

function mjwpress_register() {
    $args = array(
        'label' => __('Press'),
        'singular_label' => __('Press'),
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'post',
        'new_item' => __('New Press Item'),
        'hierarchical' => false,
        'rewrite' => true,
        'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'comments', 'revisions', 'page-attributes', 'post-formats')

    register_taxonomy('press-category', array('article'), 
            'label' => 'Press Story Category', 
            'singular_label' => 'press-story-category',
            'public' => TRUE,
            'show_tagcloud' => TRUE,
            'hierarchical' => TRUE,
            'query_var' => TRUE,
            'menu_position' => 5,
            'rewrite' => TRUE)

    register_post_type( 'mjwpress' , $args );

add_action('inthenews_init', 'inthenews_init');
add_action('save_post', 'save_mjwpress_options');

function inthenews_init(){
    add_meta_box('newsmeta', 'Press Options', 'mjwpress_meta_options', 'mjwpress', 'normal', 'low');


function mjwpress_meta_options(){
    global $post;
    $custom = get_post_custom($post->ID);
    $linkurl = $custom['linkurl'][0];
    $linktitle = $custom['linktitle'][0];

<div class='form-wrap'>
    <div class='form-field'>
        <label for='linkurl'>Link to External Publication:</label>
        <input name='linkurl' value='<?php echo $linkurl; ?>' />
        <p>E.g. http://www.example.com/article-title.php</p>

    <div class='form-field'>
        <label for='linktitle'>Title of External Publication:</label>
        <input name='linktitle' value='<?php echo $linktitle; ?>' />
        <p>E.g. Lib Dem Voice</p>


function save_mjwpress_options(){
    global $post;
    update_post_meta($post->ID, 'linkurl', $_POST['linkurl']);
    update_post_meta($post->ID, 'linktitle', $_POST['linktitle']);

share|improve this question
up vote 0 down vote accepted

Flush your permalinks whenever you add/remove/modify a taxonomy or post type. You can do this in the backend by simply going to the permalinks page and resaving

share|improve this answer
Unfortunately I've tried that and still have the same problem. – toomanyairmiles Nov 18 '11 at 17:56
I'd also advise changing the name of the admin_init function, namespace clashes are not nice, and you should prefix all your functions for safety/compatibility – Tom J Nowell Nov 18 '11 at 18:03
Also change your permalinks and test each configuration – Tom J Nowell Nov 18 '11 at 18:04
Oddly enough it works with the default config, but everything else 404's! – toomanyairmiles Nov 18 '11 at 19:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.