Database Query To Add Post In A Category In WordPress Blog?

Posted by


Please use this code to add post in a defined category via simple database query:

$wpdb->query(“INSERT INTO $wpdb->post2cat (post_id, category_id)VALUES (5, 1)”);

This will add post no. 5 to category no. 1.


Shane G.

Leave a Reply

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