optimal path in the custom post type
Today I will guide you to the optimal path in the custom post type.
When making a sales page in wordpress custom post type, we use, but how to optimize the path is not well known.
The structure of a product path defaults as follows: http://abc.com/custom-post-type-title/product-title, the path so it is not good for google too, which, starting cell work.
First you add the following code to the file offline funcions.php
function book_rewrite_rule() {
add_rewrite_rule('(.*?)$', 'index.php?custom-post-type-title=$matches[1]', 'top');
}
add_action('after_theme_setup', 'book_rewrite_rule');
function remove_slug($permalink, $post, $leavename) {
$permalink = str_replace(get_bloginfo('url') . '/custom-post-type-title' , get_bloginfo('url'), $permalink);
return $permalink;
}
add_filter('post_type_link', 'remove_slug', 10, 3);
your attention parameter “custom-post-type-title”, you replace it with custom post type that you have declared okay.
then you add the following code into the file. htaccess file in the root directory
RewriteRule ^custom-post-type-title/(.+)$ /$1 [R=301,L]
parameter “custom-post-type-title”, you replace it with custom post type that you have declared okay.