/ Published in: PHP
                    
                                        
so you want to have your url structure like :
yourdomain.com/post-type/286
add the following snippet to your functions.php and change the post-type names where appropriate
                yourdomain.com/post-type/286
add the following snippet to your functions.php and change the post-type names where appropriate
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
add_action('init', 'post-type_rewrite');
function post-type_rewrite() {
global $wp_rewrite;
$queryarg = 'post_type=post-type&p=';
$wp_rewrite->add_rewrite_tag('%post_id%', '([^/]+)', $queryarg);
$wp_rewrite->add_permastruct('post-type', '/post-type/%post_id%', false);
}
add_filter('post_type_link', 'post-type_permalink', 1, 3);
function post-type_permalink($post_link, $id = 0, $leavename, $sample) {
global $wp_rewrite;
$post = &get_post($id);
if ( is_wp_error( $post ) )
return $post;
$newlink = $wp_rewrite->get_extra_permastruct('bodumanzaru');
$newlink = home_url(user_trailingslashit($newlink));
return $newlink;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                