Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 11 months ago.

Assisted by: Long Nguyen.

Author Posts
January 6, 2023 at 7:08 pm #12766413

Florian

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?

Is there a similar example that we can see?

What is the link to your site? hidden link

January 9, 2023 at 2:37 am #12772555

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi there,

Thank you for contacting WPML support.

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:


define( 'WP_MAX_MEMORY_LIMIT', '256M' );
define( 'WP_MEMORY_LIMIT', '128M' );

After adding the code you can confirm that the memory was changed correctly from WPML > Support > WordPress > Memory limit.

2. Make sure all products and product categories are translated completely.

3. Please see if any of the following tickets are helpful:
- https://wpml.org/forums/topic/get-translated-terms-with-get_the_terms/#post-6482389
- https://wpml.org/forums/topic/how-to-correlate-translated-and-base-language-terms/#post-6272817

4. Please see WPML Hooks Reference at https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#hook-1215380 for details, specially wpml_get_element_translations. In this reference, you may find several useful hooks and examples of how to use them. I hope you may find one to best suit your needs.

Lastly, if you would want to contact an experienced developer, please see https://wpml.org/contractors/.

Regards.

January 11, 2023 at 12:39 pm #12794987

Florian

Hello, Long.

I want the same product base, product category, and shop page for all languages.

I want something like this:

Product page: hidden link
Category Page: hidden link not working now
Product Page: hidden link

January 12, 2023 at 5:09 am #12800483

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

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.

Please read more on WooCommerce documentation https://woocommerce.com/document/permalinks/

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.