wp query – WP function to get wp_term.name by wp_term.slug


I have the following query, what gets the name of the wp_term.name by wp_term.slug by the given post id and slug:

SELECT t.name FROM wp_posts p
    INNER JOIN wp_term_relationships tr ON tr.object_id = p.id
    INNER JOIN wp_terms t ON tr.term_taxonomy_id = t.term_id
    WHERE p.id = 1451
    AND t.slug = 'xxx';

It works great. But is it possible to get it by WPQuery object or a built in WP function to get the name somehow?

vaso123 2 weeks 2023-01-12T04:29:46-05:00 0 Answers 0 views 0

Leave an answer