Hello, welcome to therichpost.com. In this post, I will tell you How to Get WordPress Posts With Mysql Like Condition? WordPress is the best cms. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress.
In this post, we will get wordpress post data with mysql query.
Here is the working code for to Get WordPress Posts With Mysql Like Condition and you can add this into theme’s any template file:
$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 get_the_post_thumbnail( $results->ID, ‘thumbnail’ );
There are so many tricks in wordpress and I will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com
You Might Also Like
Hello to all, welcome again on therichpost.com. In this post, I will tell you, Wordpress - Custom Rest Api for...