I wanna compare "postType",
<input name="postType" value="" id="postType" required>
with a column in my DB called "post_type" (from table wp_posts). So, I just wanna the results with matches the input with the value in post_type column. I don't know if I can do a for each or put a SQL statement. Examples:
if($_POST["postType"] == "page") {
//results
}
So, if I put "page" in my input it returns the correct results.
What I've done to the general case:
$term = $_POST["postType"];
$result = $wpdb->get_results("SELECT count(ID) FROM $wpdb->posts WHERE post_type = '".$term."')");
foreach($result as $resultX) {
if($_POST["postType"] == $resultX) {
//results
}
}
But it is not working