I'm trying to update a category's description via SQL. I "created php code" from the SQL query I did in PHPmyadmin and this is what it gave me:
$sql = "UPDATE `table`.`wp_term_taxonomy` SET `description` = \'new-description\' WHERE `wp_term_taxonomy`.`term_taxonomy_id` = 105;";
I tried adding this to my Wordpress template but it didn't work. Any ideas what I need to do to this code to make it work?
Thanks in advance!
It's probably
`table`
that doesn't belong. Try:
$sql = "UPDATE `wp_term_taxonomy` SET `description` = 'new-description' WHERE `wp_term_taxonomy`.`term_taxonomy_id` = 105";
I also took out the \
s around the description, and the ;
in the string. You don't need to escape single quotes in a double-quote delimited string.
Figured it out! Here is the correct code in case anyone is interested:
<?php
$wpdb->query(
"
UPDATE $wpdb->term_taxonomy
SET description = 'description'
WHERE wp_term_taxonomy.term_taxonomy_id = 105
"
);
?>