1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$post_name = 'my-post'; $querystr = 'SELECT * FROM "wp_posts" WHERE "post_name" = "' $post_name . '"'; $results = $wpdb->get_results($querystr, OBJECT); if(!empty($results)) { foreach ($results as $result) { // do your magic break; } } else { echo 'post '. $post_name . ' was not found.'; } // see: https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query |