Saturday, 19 August 2017

Get Wordpress Posts With Mysql Like Condition

Here is the code to Get Wordpress Posts With Mysql Like Condition:

$today = "top 250";
$sql = "SELECT * FROM wp_posts WHERE post_title LIKE '$today%' and post_type = 'page' limit 1";
$result = $wpdb->get_results($sql) or die(mysql_error());
   foreach($result as $results)
{
echo $results->post_title."<br>";
echo $results->post_content."<br>";
echo get_the_post_thumbnail( $results->ID, 'thumbnail' );
}

No comments:

Post a Comment

Google Map Filter Api Example

Here is Google Map Filter Api Example: