Custom permalink request $request_noslash QUERY
-
Hi, i like this plugin.
But i am a developer and i was in a sitauation where your plugin was messing up links and results. All went ok until we added pages for custom post types trying to overwrite the archive link with a custom link that was exactly like archive one.
I tried to debug your plugin and i found that this query isn’t quite good:$sql = $wpdb->prepare("SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value, $wpdb->posts.post_type, $wpdb->posts.post_status 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 "....etc
Since it return results when it should not.
This query works for me, and all seems to be ok.
Maybe, just maybe you should change the query. It’s just an observation so you can update the code better since this is a good plugin.$sql = $wpdb->prepare("SELECT DISTINCT(posts.ID) AS ID, posts.post_title as post_title, posts.post_status as post_status, posts.post_type as post_type, TRIM(TRAILING '/' FROM post_meta.meta_value) as meta_value FROM $wpdb->posts AS posts , $wpdb->postmeta AS post_meta WHERE posts.ID = post_meta.post_id AND post_meta.meta_key = 'custom_permalink' AND post_meta.meta_value = '%s' AND posts.post_status != 'trash' AND posts.post_type != 'nav_menu_item' LIMIT 1",$request_noslash);
…in function custom_permalinks_request($query) { … }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom permalink request $request_noslash QUERY’ is closed to new replies.