• Resolved stipto

    (@stipto)


    Hello,

    I don’t know if this is multisite-related or not, but I recently migrated a Drupal database to WP and a lot of articles don’t generate a valid slug. I use the /%category%/%postname%/ in Permalink settings.

    For example: The articles post title is Why this/that?
    Generated the following slug: /why-this/that
    Wich obviously doesn’t work.

    When I create a new article it generates a good slug. No problems.

    Anyone have a thought on this??

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    IIRC / is a ‘reserved’ character in the slug and cannot be used.

    That’s a general WP issue, not MultiSite. I also can’t think of ways to ‘auto-fix’ that. You’d have to go to each post and edit the slug :/

    Thread Starter stipto

    (@stipto)

    Ha! That’s only a last-resort-solution with over 5.000 posts.

    It also happens with characters like ! and ‘ so not only the /
    And this problem only occurs on my imported articles. When I create a new one, it generates a good slug.

    So maybe I can perform a query in SQL that finds all url’s that have these reserved characters and replaces them by valid things? Only I wouldn’t know how to write this.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I’ve never tried (ow, 5000!)

    If possible, I’d dump the posts (all of ’em) and see if you can re-import with ‘clean’ URLs. If not….

    WHAT FOLLOW IS ALL UNTESTED THEORY!!!!

    This post on “Transliterate existing cyrillic slugs (post_name) in wordpress” may help: http://snipplr.com/view/50246/transliterate-existing-cyrillic-slugs-postname-in-wordpress/

    So you’d want something like

    $iso = array(
       "!"=>"-","/"=>"-"
      );

    And so on.

    Thread Starter stipto

    (@stipto)

    Hey Ipstenu,

    Thanks for your help. I couldn’t fix it yet though.. I know the basic SQL query but the special characters give errors. This is what I got thusfar:

    update wp_posts set post_name = replace(post_name, ‘find this string’, ‘replace found string with this string’);

    As I found out, the slug is in the post_name field in wp_posts.
    The only thing I need to know is how insert those special characters into the ‘find this string’ part. If I insert a ‘ then it gives me this error: #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”’, ‘-’)’ at line 1

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I think it’s because your quotes are ‘smart’ quotes…

    update wp_posts set post_name = replace(post_name, 'find this string', 'replace found string with this string');
    Thread Starter stipto

    (@stipto)

    Do you mean that I didn’t fill in the string? The actual queries I’m trying are like this:

    update wp_posts set post_name = replace(post_name, ‘:’, ‘-‘);

    Or

    update wp_posts set post_name = replace(post_name, ‘?’, ‘-‘);

    Now I don’t know what ‘smart’ quotes mean.
    Hey and thanks for helping me this much, really appreciate it!! 🙂

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Smart Quotes: http://en.wikipedia.org/wiki/Quotation_mark_glyphs

    And … you have to use special kinds of quotes in various places here…

    AND since WordPress’s form will EAT those quotes, read this: http://forums.mysql.com/read.php?10,405739,405745#msg-405745

    That’s the specific kind of quotes you’ll need 🙂

    Thread Starter stipto

    (@stipto)

    You’re totally right! Thanks!! I’m able to do everything I need now.

    +1 for you.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Glad to help! 😀

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Multisite Permalinks creates broken URL's with special characters’ is closed to new replies.