我正在尝试修改一个插件,该插件搜索posts表,并让它也搜索POSTETA表中的meta\\u值。
原始代码为:
if (!($index_page = $wpdb->get_row("SELECT ID AS id, post_name AS slug FROM {$wpdb->posts} WHERE (post_content LIKE \'%[" . W2DC_MAIN_SHORTCODE . "]%\' OR post_content LIKE \'%[" . W2DC_MAIN_SHORTCODE . " %\') AND post_status = \'publish\' AND post_type = \'page\' LIMIT 1", ARRAY_A)))
到目前为止,我的代码是:
if (!($index_page = $wpdb->get_row("SELECT {$wpdb->posts}.ID AS id, {$wpdb->posts}.post_name AS slug FROM {$wpdb->posts} INNER JOIN {$wpdb->postmeta} ON ({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id) WHERE 1 = 1 AND (({$wpdb->postmeta}.meta_value LIKE \'%[" . W2DC_MAIN_SHORTCODE . "]%\') OR ({$wpdb->posts}.post_content LIKE \'%[" . W2DC_MAIN_SHORTCODE . "]%\')) AND {$wpdb->posts}.post_status = \'publish\' AND {$wpdb->posts}.post_type = \'page\' AND (({$wpdb->postmeta}.metakey = \'_content_field_6\') OR ({$wpdb->postmeta}.meta_key = \'_content_field_11\'))LIMIT 1", ARRAY_A)))
但它不起作用,我不明白为什么。。。感谢您的帮助。