Query utili: differenze tra le versioni

Da Webmobili Wiki.
Nessun oggetto della modifica
Riga 37: Riga 37:
WHERE p.post_type = 'product'
WHERE p.post_type = 'product'
   AND p.post_status = 'trash';
   AND p.post_status = 'trash';
</syntaxhighlight>
=== Aggiornare Siteurl e Home ===
<syntaxhighlight lang="sql">
SELECT option_name, option_value FROM wp_options WHERE option_name in ('siteurl','home');
</syntaxhighlight>
</syntaxhighlight>

Versione delle 08:48, 9 ott 2025

Trovare gli utenti Admin

SELECT u.ID, u.user_login, u.user_email
FROM wp_users u
INNER JOIN wp_usermeta um ON u.ID = um.user_id
WHERE um.meta_key = 'wp_capabilities'
  AND um.meta_value LIKE '%administrator%';

Woocommerce

Stati del prodotti:

  • publish
  • draft
  • pending
  • trash

Visualizzare Prodotti nel cestino

SELECT p.ID, p.post_title, p.post_status, p.post_type
FROM wp_posts p
WHERE p.post_type = 'product'
  AND p.post_status = 'pending';

SELECT p.ID, p.post_title, p.post_status, p.post_type
FROM wp_posts p
WHERE p.post_type = 'product_variation'
  AND p.post_status = 'trash';

Eliminazioni prodotti da Cestino

DELETE p, pm, tr
FROM wp_posts p
LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id
LEFT JOIN wp_term_relationships tr ON p.ID = tr.object_id
WHERE p.post_type = 'product'
  AND p.post_status = 'trash';


Aggiornare Siteurl e Home

SELECT option_name, option_value FROM wp_options WHERE option_name in ('siteurl','home');