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.

My articles are not standard posts but custom post types (not sure about how to formulate this exactly). When viewing an article in single view, the URL is : my_site.com/custom_type_name/article_title, whereas I want: my_site.com/article_title, just like with normal posts.

How to achieve that ?

share|improve this question

1 Answer 1

Use the post_type_link hook, like this for use hash in link

faq is the example custom post type

add_action( 'post_type_link', 'wpse70763_post_type_link', 10, 2 );
function wpse70763_post_type_link( $link, $post ) {

    $post_type = 'faq';

    if ( $post->post_type === $post_type )
        $link = get_post_type_archive_link( $post_type ) . '#' . $post->post_name;

    return $link;
}

then unset($wp_rewrite->extra_permastructs['faq'])

On the init of your CPT unset the pemastructure

share|improve this answer
    
Thanks but I don't want a hash.. –  drake035 Oct 29 '12 at 13:05
    
Yes, this is only a example. You must use the source. This is not the ready solution. –  bueltge Oct 29 '12 at 21:09

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.