Analog category_and (WP) in sql query

Thanks Milo for the answer! This block of code selects posts that have two categories at the same time. ( ( SELECT COUNT(1) FROM wp_term_relationships WHERE term_taxonomy_id IN (35,33) AND object_id = wp_posts.ID ) = 2 ) Where 35,33 are categories IDs and 2 – number of categories.

How to create a database table?

There are several things going on here Firstly, your dbDelta call never receives a CREATE SQL statement. $sql is only defined if the if statement is true, and if your developer environment is setup correctly then running this code should generate PHP Warnings. You’re actually running dbDelta(”); dbDelta already does this check though. It’s not … Read more

Using $wpdb to insert data into a table

If i understand well, users will update their datas in front-office, and you need to save datas in your custom table. I think you must check on wp_ajax process which will allow you to post datas in JS to a WP_ajax handler. This handler will be a PHP function, (can be written in your theme’s … Read more