I have custom categories in wordpress named “Product Categories” with custom post type “Products”.
i want to change urls from
somesite.com/product/airconditioner/voltas/productname
to
somesite.com/airconditioner/voltas/productname
Code to register post and categories
class aw_products_post_type {
function __construct(){
$this->aw_register_post_type();
$this->aw_add_post_type_actions();
$this->aw_add_post_type_filters();
}
public function aw_register_post_type(){
// Labels
$labels = array(
'name' => __('Products','framework'),
'singular_name' => __('Product','framework'),
'add_new' => __('Add new','framework'),
'add_new_item' => __('Add new product','framework'),
'edit_item' => __('Edit','framework'),
'new_item' => __('New product','framework'),
'view_item' => __('View product','framework'),
'search_items' => __('Search product','framework'),
'not_found' => __('No product found','framework'),
'not_found_in_trash' => __('No product found in trash','framework'),
'parent_item_colon' => '',
'menu_name' => __('Products','framework')
);
$short_url = (get_option('tz_products_short_url') != '') ? get_option('tz_products_short_url') : 0;
$slug_first_part = ((get_option('tz_custom_products_slug') != '') ? get_option('tz_custom_products_slug') : 'product');
if($short_url == 1) {
$slug = $slug_first_part;
} else {
$slug = $slug_first_part."/%product_category%/%product_brand%";
}
// Arguments
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri().'/img/admin/admin- products.png',
'rewrite' => true,
'capability_type' => 'post',
'rewrite' => array("slug" => $slug), // Permalinks format
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'taxonomies' => array('post_tag'),
'supports' => array('title','editor','author','thumbnail','excerpt', 'comments', 'tags')
);
Value of tz_custom_products_slug in wp_option -> Product
Solutions tried in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^product/(.+)$ /$1 [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
</IfModule>
The above solution didn’t worked.
Solution 2 Tried and failed as follows:
changed this from above code $slug = $slug_first_part.”/%product_category%/%product_brand%”;
to this
$slug = “/%product_category%/%product_brand%”;
This caused 2nd custom taxanomy as page not found that is brands that shows urls like this :
sitename.com/brands/acer/
If you need the whole custom taxanomy code for brand and product_category let me know.
To check the original urls check it on : https://www.pricereview.in/product/digital-cameras/olympus/olympus-sz-17-digital-camera/
Similarly my custom taxanomy contains basename categories. i also want to remove it.
This is how urls are working. i want to convert this
https://www.pricereview.in/categories/mobile-price-in-india/
to
https://www.pricereview.in/mobile-price-in-india/
]]>Thanks.
]]>At the moment i’m using a wonderful plugin named Custom Post Type UI and doing (for 90%) the work perfectly.
It allows me to make custom post types, taxanomies and automaticly? rewrites the URL.
But my problem is:
I’ve created a post type, named ‘books’ and a taxanomy named ‘author’ and added a book named ‘Bookie1’.
I want the author name( example ‘Martin’) in the url when i’m navigating to the ‘Bookie1’, so the URL would be:
books/martin/bookie1
My current URL is:
books/bookie1
It works with the standard category, but not the custom one. Any ideas how i can ‘tweak’ the custom taxanomy into the URL?
]]>And besides that, i can’t get a custom themefile to work neither.
For example: archive-categories.php or taxanomy-categories.php.
What am I doing wrong?
Thanks in advance
Thanks.
]]>I was traditionally putting names in the tags section, but with the new custom taxonomies feature I have started relegating a “people” taxonomy for this use. Is there a way to mass edit posts, or shift “name tags” into the people taxonomy?
Also, I would like to mass apply thumbnails to many posts at a time. Is there a way to do this?
Thanks for any and all help!
]]>