mysql - How do I filter tags down to specific categories? -


i have working query here retrieve tags used in last 60 days.

$term_ids = $wpdb->get_results(" select distinct wp_term_taxonomy.term_id, wp_terms.name wp_term_taxonomy inner join wp_term_relationships on wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id inner join wp_posts on wp_posts.id = wp_term_relationships.object_id inner join wp_terms on wp_terms.term_id = wp_term_taxonomy.term_id wp_term_taxonomy.taxonomy = 'post_tag' , date_sub(curdate(), $show_tags_in_days) <= $wpdb->posts.post_date", array_a); 

what need modify tags used in last 60 days , in specific wordpress category. used on category page of wordpress. i've been fiddling awhile , think i've got myself confused. there way join or should run 2 separate queries?

i managed figure out. here query came with.

select distinct wp_term_taxonomy.term_id, wp_terms.name wp_terms inner join wp_term_relationships on   wp_term_relationships.term_taxonomy_id=wp_terms.term_id inner join wp_term_taxonomy on wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id inner join wp_posts on wp_posts.id=wp_term_relationships.object_id wp_term_taxonomy.taxonomy = 'post_tag' , wp_posts.id in ( select wp_posts.id wp_terms inner join wp_term_relationships on wp_term_relationships.term_taxonomy_id=wp_terms.term_id inner join wp_term_taxonomy on wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id inner join wp_posts on wp_posts.id=wp_term_relationships.object_id wp_term_taxonomy.taxonomy = 'category' , wp_terms.term_id=$cur_cat_id) limit 10 

here more in-depth explanation: http://www.ohthecode.com/wordpress/most-used-tags-in-wordpress/


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -