SQL Querries This functions gets the first post with the specified key and value in the postmeta table: function getPostIdByMetaKeyAndValue($key, $value) { global $wpdb; $meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".$wpdb->postmeta." WHERE meta_key=%s AND meta_value=%s", $key, $value ) ); if (is_array($meta) && !empty($meta) && isset($meta[0])) { $meta = $meta[0]; } if (is_object($meta)) { return $meta->post_id; } else { return false; } } Links $wpdb – WordPress database access abstraction class.Ultimate Guide to meta_query unsere-schule.org × SQL Querries Code: Infos: unsere-schule Codes