• Attempting to set taxonomyslug to a slug with anything beyond basic alphanumeric (plus hyphens/underscores) leads to all posts being displayed, possibly due to the regex on line 75 of functions.php. Could that be extended to allow URL-escaped characters, or alternately, could a taxonomyid parameter be added that would filter by ID instead of slug?

    Thanks for any help!

    Dan

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Dan Wich (MailMechanic)

    (@mailmechanic)

    Looks like a single character change will fix it, just adding the % to the regex to allow for the URL-escaped characters. So Line 75 of functions.php would become:

    if(!preg_match('/^([,a-z0-9\_\-%]+)$/', $wmis_atts[$wmisattskeys_single])){  $wmis_atts[$wmisattskeys_single] = $default_wmis_params[$wmisattskeys_single];}    
    Plugin Author WPOrbit Support

    (@kaushik07)

    Hi @mailmechanic

    Thanks for reporting this. Could you share use case of this? Some steps would help replicate and understand what the issue is.. Perhaps are you trying to generate the shortcode dynamically by taking values from the URL?

    Thread Starter Dan Wich (MailMechanic)

    (@mailmechanic)

    Hi @kaushik07,

    In this particular case, the site has special characters in the post tags. WordPress URL-encodes those for the tag slugs, which are what is used in the plugins taxonomyslug parameter. So when the shortcode (either manually written or through the generator tool) uses the taxonomyslug parameter, it gets “cleaned up” because those URL-encoded characters aren’t alphanumeric.

    A way to reproduce would be to have a tag that uses a comma, ampersand, colon, or slash and try and display it with the shortcode generator tool. You’ll see the tag filter isn’t actually applied.

    Plugin Author WPOrbit Support

    (@kaushik07)

    Hi @mailmechanic Seems WordPress does not allow having comma, ampersand, colon, or slash in the “slug” of terms. So curious how were you able to have term slugs containing these characters.

    Thread Starter Dan Wich (MailMechanic)

    (@mailmechanic)

    Oh, you’re right! I should’ve checked it on a clean site, this was on a client site where it turns out a sanitize_title filter was extending the allowed characters for URLs beyond alphanumeric.

    I’m trying to think of the best approach if allowing percent signs isn’t an option, because then it’d be a struggle SEO-wise for the client to move the existing tag slugs/URLs to not have commas. Would you be open to adding a taxonomyid parameter that worked the same as the category parameter, taking IDs instead of slugs? I could write up an update to the plugin’s functions.php if it’d save you hassle.

    Plugin Author WPOrbit Support

    (@kaushik07)

    Hi Dan (@mailmechanic)

    The parameter name has been misleading in our plugin – taxonomyslug should actually be “taxonomyterms” because taxonomyname is what’s already the slug of taxonomy.

    For your use case we will work on introducing a new shortcode parameter termsfield which can have value from “slug” or “term_id” that allow you to choose what you want to supply. This also means we will have to rename taxonomyslug to something better like taxonomyterms however this means we need to ensure how to do it in a way that does not break existing sites using taxonomyslug in the shortcode.

    Thread Starter Dan Wich (MailMechanic)

    (@mailmechanic)

    Much appreciated, thank you!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘taxonomyslug filtering not working with non-alphanumeric slugs’ is closed to new replies.