Currently my permalink setting is /paper/%postname%/.

I am developing a plugin, so the following is done during the activation.

I am programatically adding a new custom-post-type called 'meta', like this (at 'init'):

register_post_type( POST_TYPE,
  'labels' => array('menu_name' => 'meta'),
  'public' => true,
  'rewrite' => array('with_front'=>false,'slug'=>'meta','pages'=>false)

Then in the activation I programatically added a meta post, and use get_permalink(). But I get the following url:


This url leads to the 'not found' page. The correct url should be:


In the admin meta post edit page, the displayed permalink is the correct http://localhost/wordpress/meta/faq

I also tried to flush_rewrite_rules(); before I call get_permalink(). But it didn't work.

Does anyone have any idea?

  • Are you able to consistently reproduce this by creating more posts and getting wrong results from get_permalink()?
    – soulseekah
    Mar 13, 2012 at 11:15

1 Answer 1


At what stage are you registering your post type? If it's going right in the admin I'm thinking that you might be registering your post type too late. It has to be done on init to work...

Also, removing the 'pages'=>false might just fix it.

  • yes it is done in init like add_action('init', 'set_post_type_meta');, NOT inside the activation function. I tried removing it but it didn't work either.
    – lulalala
    Sep 29, 2011 at 8:48
  • 1
    @lulalala Try adding a flush_rewrite_rules(); after registering your custom post type. Jun 28, 2012 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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