Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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

 
discard

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.