What's new

SQL Queries for WordPress



PHP:
$search = $wpdb->escape($search);
$posts = $wpdb->get_results("SELECT ID, post_title, post_content FROM $wpdb->posts WHERE post_status = 'publish' AND (post_title LIKE '%$search%' OR post_content LIKE '%$search%') ORDER BY post_title LIMIT 0,5");

Source: WordPress Plugin Development: Beginner's Guide


Screen Shot 2021-09-12 at 6.23.49 PM.png
Source: Wordpress Web Application Development - Third Edition





 
Last edited:
Top