• Resolved billerr

    (@billerr)


    We are having trouble with auto-generation of slugs in hierarchical taxonomies (by leaving the slug field empty). WordPress should generate a slug from the sanitized term name, and if any conflict occurs, a unique slug would be created using the term’s hierarchy.

    It seems that Polylang is interfering with this mechanism using the ‘pre_term_slug’ filter: Polylang creates a slug before WordPress can detect the provided empty value. If any conflict occurs, Polylang doesn’t create a unique slug, but let’s the duplicate slug pass through and fail.

    Can we update the plugin to move the ‘set_pre_term_slug’ hook later, right before saving the term to the database? Or at least provide an admin option to disable this functionality?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    The goal of this method is to be able to create same terms in different languages.
    Unfortunately, it’s not possible to delay the process because WP would prevent to create the term.
    However if the behavior of Polylang doesn’t match your needs it’s possible to remove the filter:
    remove_filter( 'pre_term_slug', array( PLL()->terms, 'set_pre_term_slug' ) );

    Thread Starter billerr

    (@billerr)

    Hello!

    OK I understand – we’ll probably remove the filter and replicate the desired polylang behaviour ourselves because we rely on autogenerated unique slugs for our end users.

    It just seemed weird that this filter short-circuits the WordPress fallbacks and doesn’t provide these safe-checks too. If it needs to stay this way, it would be useful to have polylang replicate the WordPress fallback and also auto-generate unique slugs.

    Thanks for your guidance!

    • This reply was modified 4 months, 2 weeks ago by billerr.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.