Skip to main content
8 events
when toggle format what by license comment
Jul 30, 2015 at 21:00 history edited CharlesStamp CC BY-SA 3.0
Added updated code to reflect advice given
Jul 30, 2015 at 16:39 comment added bonger You put the sql string in the prepare() not vice versa - see @userabuser answer...
Jul 30, 2015 at 15:59 comment added CharlesStamp @bonger I tried adding $wpdb->prepare but the outcome is the same. global $wpdb; $itemName = get_the_title( $ID ); $results =$wpdb->get_results("SELECT ID FROM $wpdb->posts where $wpdb->prepare($wpdb->posts.post_title) LIKE $wpdb->prepare('%$itemName%') AND $wpdb->posts.post_status = 'publish' ORDER BY post_title ASC", OBJECT);
Jul 30, 2015 at 15:45 comment added CharlesStamp @bonger - Can that be used within the SQL query itself? There are several ways to remove the single quotation from $itemName but every attempt I've made to use it in the query fails, and breaks all searches, even those that previously worked. Part of the difficulty I'm finding is due to trying to use single quotes within an SQL query.
Jul 30, 2015 at 10:51 answer added Adam timeline score: 1
Jul 30, 2015 at 10:46 comment added Adam Do you have multiple posts like: TODAY'S WEATHER IS NICE with apostrophe?
Jul 30, 2015 at 8:14 comment added bonger Use $wpdb->prepare() codex.wordpress.org/Class_Reference/wpdb#Placeholders
Jul 30, 2015 at 8:00 history asked CharlesStamp CC BY-SA 3.0