Wordpress - I want to use a title condition for displaying info on a page, from a MySQL table "country".
The condition must compare the title with the names in the column "name" and when it match a value than display on the page the text from column "description" from the same row with the matching value. Example : title(USA)=column name (USA) get/fetch column (description) (the description from row USA).
I had tryed a code
<?php
$page_name = $wp_query->post->post_name;
query_posts('category_name='. $page_name);
?>
<?php global $wpdb;
$result = $wpdb->get_row ("SELECT name FROM country WHERE parent IN (SELECT parent FROM country WHERE name == '$page_name'"));
if ($result->num_rows == 0) {
echo '<div>No matches found</div>';
} else {
$i = 0;
while ($row = $result->fetch_row(description)) {
if ($row["name"] == '1') {
echo '<div id="description' . $i . '"></div>';
}
$i++;
}
echo $result->description;
}
?>
I have foud hier a code to display the title
<?php echo get_the_title($ID); ?>
and a code to use the title condition
<?php
$title = the_title('', '', false);
if($title == 'conditional post title'){
// your stuff here
}
?>