Viewing 3 replies - 1 through 3 (of 3 total)
  • The problem is with mysql_real_escape_string in custom_permalinks.php. There seem to be some solutions online, but I found simply removing that part of the code worked best for now, at least if you’re familiar with doing so.

    Looks like we need an update for 3.9 indeed ??

    In the WP plugins directory, in custom-permalinks, in custom-permalinks.php find the following lines:

    $sql = “SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value, $wpdb->posts.post_type FROM $wpdb->posts “.
    “LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE “.
    ” meta_key = ‘custom_permalink’ AND “.
    ” meta_value != ” AND “.
    ” ( LOWER(meta_value) = LEFT(LOWER(‘”.mysql_real_escape_string($request_noslash).”‘), LENGTH(meta_value)) OR “.
    ” LOWER(meta_value) = LEFT(LOWER(‘”.mysql_real_escape_string($request_noslash.”/”).”‘), LENGTH(meta_value)) ) “.
    ” AND post_status != ‘trash’ AND post_type != ‘nav_menu_item'”.
    ” ORDER BY LENGTH(meta_value) DESC, “.
    ” FIELD(post_status,’publish’,’private’,’draft’,’auto-draft’,’inherit’),”.
    ” FIELD(post_type,’post’,’page’),”.
    “$wpdb->posts.ID ASC LIMIT 1”;

    Replace them with:

    $sql = $wpdb->prepare(“SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value, $wpdb->posts.post_type FROM $wpdb->posts “.
    “LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE “.
    ” meta_key = ‘custom_permalink’ AND “.
    ” meta_value != ” AND “.
    ” ( LOWER(meta_value) = LEFT(LOWER(‘%s’), LENGTH(meta_value)) OR “.
    ” LOWER(meta_value) = LEFT(LOWER(‘%s’), LENGTH(meta_value)) ) “.
    ” AND post_status != ‘trash’ AND post_type != ‘nav_menu_item'”.
    ” ORDER BY LENGTH(meta_value) DESC, “.
    ” FIELD(post_status,’publish’,’private’,’draft’,’auto-draft’,’inherit’),”.
    ” FIELD(post_type,’post’,’page’),”.
    “$wpdb->posts.ID ASC LIMIT 1”,$request_noslash,$request_noslash . “/”);

    This restored my permalinks to working order. As always, make a backup of the custom-permalinks.php file before modifying it in case something goes horribly wrong. Good luck!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help. 404 error’ is closed to new replies.