Tell us what you are trying to do?
I'm attempting to create the same URL base for a products and a category. I can do it in my default language, but in other languages I receive an error. I use below code
$new_rules = array();
$terms = get_terms( array(
'taxonomy' => 'product_cat',
'post_type' => 'product',
'hide_empty' => false,
));
if ( $terms && ! is_wp_error( $terms ) ) {
$siteurl = esc_url( home_url( '/' ) );
foreach ( $terms as $term ) {
$term_slug = $term->slug;
$baseterm = str_replace( $siteurl, '', get_term_link( $term->term_id, 'product_cat' ) );
// rules for a specific category
$new_rules[$baseterm .'?$'] = 'index.php?product_cat=' . $term_slug;
// rules for a category pagination
$new_rules[$baseterm . '/page/([0-9]{1,})/?$' ] = 'index.php?product_cat=' . $term_slug . '&paged=$matches[1]';
$new_rules[$baseterm.'(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?product_cat=' . $term_slug . '&feed=$matches[1]';
}
}
return $new_rules + $rules;
Is there any documentation that you are following?
We do not normally offer support for custom code, but I can suggest you a few pointers:
1. Increase the WP memory limit: While checking the debug info, I see that the WordPress Memory Limit is below the requirements. The minimum requirements are 128M, but we do recommend 256M and the debug information of your site shows it set to 40M. Please check this link for more details https://wpml.org/home/minimum-requirements/.
You can increase it by adding the following code in your wp-config.php file, right before the /* That’s all, stop editing! Happy publishing. */ line:
Using the same slug (custom base) for product and product category is not recommended and might lead to any unexpected issues.
Note: The product Custom base setting should NOT conflict with the Taxonomy permalink settings. If you set the product base to shop for example, you should NOT set the product category base to shop too, as this will not be unique and cause a conflict. WordPress requires something unique so it can distinguish categories from products.
So if you are trying to use a custom code to add the same custom base for product and product category, I would recommend you contact one of our certified partners that will be more than happy to help you with this. In this link, you will find a list of our certified partners: https://wpml.org/contractors/
Thanks and have a good day.
The topic ‘[Closed] Using Same Category base for product and Shop’ is closed to new replies.