Viewing 6 replies - 1 through 6 (of 6 total)
  • I would suggest switching the permalink structure around. It is not advisable to use %postname% first. It’s much better for performance to do:

    /%post_id%/%postname%/

    Thread Starter chefobat

    (@chefobat)

    Hello f00bar,

    Thanks for the suggestion. I have actually read somewhere else that it is better to use /%post_id%/%postname%/ structure for better performance, however when i tested it that way my original problem did not get solved.

    Again https://www.mybwordpressdomain.com/post_id/postname/ and https://www.mybwordpressdomain.com/post_id/postname_with_spelling_mistake/ did not point to the same page. Instead the second one just gave 404 which is what i try to avoid.

    Best regards.
    Stefan

    If you spell it wrong, then it will go the incorrect page, that is correct. But, why would that happen? If someone visits your page then all the links will point to the correct page, surely?

    Thread Starter chefobat

    (@chefobat)

    hello f00bar,

    Because i’m migrating from non-wordpress platform and I have some spelling mistakes in links all over the internet. Don’t ask how that happened … just it’s that way. So I want to keep the links working as they are currently with the engine I use.

    I have enabled full query log in mysql to see how wp engine tries to find the proper post to display. Proper postname is
    burn-iso-image-with-nero-burning-rom

    I tried to access the same article with
    burn-iso-image-with-nero-burning-romance

    Here is the result of mysql log

    4 Query SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = ‘burn-iso-image-with-nero-burning-romance’ AND wp_posts.ID = 10 AND wp_posts.post_type = ‘post’ ORDER BY wp_posts.post_date DESC
    4 Query SELECT post_id FROM wp_postmeta, wp_posts WHERE ID = post_id AND meta_key = ‘_wp_old_slug’ AND meta_value=’burn-iso-image-with-nero-burning-romance’
    4 Query SELECT ID FROM wp_posts WHERE post_name LIKE ‘burn-iso-image-with-nero-burning-romance%’ AND post_status = ‘publish’

    So I want to find the place where the last select is generated and replace it with some query like

    SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID = 10 AND wp_posts.post_type = ‘post’ ORDER BY wp_posts.post_date DESC

    So that it gets the proper result.

    Ah I see..I’m not sure where you would go to alter the way it selects from the database, I’ve only been using WordPress for a week or two and haven’t gone in too deep yet. I would have thought it would be in one of the WordPress classes though? You can find these in the wp-includes folder I believe. BUt, I would make backups before you alter anything major.

    Thread Starter chefobat

    (@chefobat)

    Hello f00bar,

    First I want to thank you for you replies.

    Here is what I did to solve my little problem.

    I altered a bit the function redirect_guess_404_permalink in wp-includes/canonical.php

    After

    if ( !get_query_var(‘name’) )
    return false;

    I added

    if ( get_query_var(‘p’) ) {
    return get_permalink(get_query_var(‘p’));
    }

    I know this is not the best code but so far it does what i needed.

    I’m not good at php but i believe there is some bug in this file

    on line 69 is_singular() returns false which is not right. Also even if we enter that if clause and we find the proper post to display we still continue with the rest if the function.

    Anyway if someone of the devs reads this form they may want to take a look.

    Best regards,
    Stefan Batanov

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Permalinks question’ is closed to new replies.