i create a new post-type in wordpress. The new post-type is called work.

I want to customize the link when the user click "details button". The link is work/post_id/postname

I have a trouble to connect the link to a details page. The details page is called single-work.php In my functions.php I write these rules:

add_action( 'init', 'wpse26388_rewrites_init' );
    function wpse26388_rewrites_init(){
    add_rewrite_rule( "work/([0-9]+)/([0-9]+)?$", "single-work.php", 'top' );
 }

But there is a trouble because when the user click the link, he sees the index.php and not single-work.php. How can I fix that?

You don't need a URL rewrite. WP will show the single work post by default using the single-work.php template.

Go to Settings > Permalinks and select Custom Structure there. Put this rule in the text input:

/%post_id%/%postname%

And save the settings.

This should work for you.

  • I setting this rules but when i click the link i see a index.php and not single-work.php .There are some thing that i customize? for exaples a .htaccess file or a option when i register my post-type? – andrea poma Sep 20 '12 at 9:35
  • Your htaccess might not be writable... – Rutwick Gangurde Sep 20 '12 at 10:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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