Ich versuche, ein Plugin zu modifizieren, das die posts-Tabelle durchsucht und es auch den meta_value in der postmeta-Tabelle durchsucht.
Der ursprüngliche Code ist:
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)))
und mein Code ist bis jetzt:
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)))
aber es funktioniert nicht und ich kann nicht herausfinden, warum … jede Hilfe geschätzt.
Sie haben eine Instanz von metakey
die metakey
sein sollte.