Categories

Tuesday, June 18, 2024
#919814419350 therichposts@gmail.com
MysqlWordpress Tricks

How to Get WordPress Posts With Mysql Like Condition?

How to add custom meta title and meta description in Wordpress?

Get Wordpress Posts With Mysql Like Condition

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 $results->post_title.”<br>”;
echo $results->post_content.”<br>”;
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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.