Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 242689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:51:31+00:00 2026-05-11T20:51:31+00:00

Using WordPress, I need to generate an array of tags(terms) from posts in a

  • 0

Using WordPress, I need to generate an array of tags(terms) from posts in a particular category.

For instance, if I have two categories, “apple” and “orange”, I want an array of terms that are only used in posts in the apple category — not in the orange category. (though, if a term is used in both, that should be included)

I’ve tried using a handful of wordpress functions, but none return what I want (including tag_cloud function). My guess is I’m left with a Query call … but so far all my queries aren’t giving me the list I want.

Thanks in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:51:31+00:00Added an answer on May 11, 2026 at 8:51 pm

    I’m not sure you can accomplish what you want using the functions WordPress provides. Here’s an SQL query that seems to do what you want:

    SELECT tag_terms.name, COUNT(wp_posts.ID) FROM wp_posts 
    
    INNER JOIN wp_term_relationships AS cat_term_relationships ON wp_posts.ID= cat_term_relationships.object_ID 
    INNER JOIN wp_term_taxonomy AS cat_term_taxonomy ON cat_term_relationships.term_taxonomy_id= cat_term_taxonomy.term_taxonomy_id 
    INNER JOIN wp_terms AS cat_terms ON cat_term_taxonomy.term_id= cat_terms.term_id 
    
    INNER JOIN wp_term_relationships AS tag_term_relationships ON wp_posts.ID= tag_term_relationships.object_ID 
    INNER JOIN wp_term_taxonomy AS tag_term_taxonomy ON tag_term_relationships.term_taxonomy_id= tag_term_taxonomy.term_taxonomy_id 
    INNER JOIN wp_terms AS tag_terms ON tag_term_taxonomy.term_id= tag_terms.term_id 
    
    WHERE cat_term_taxonomy.taxonomy='category' AND cat_terms.name='apple' AND tag_term_taxonomy.taxonomy='post_tag'
    GROUP BY tag_terms.name
    

    The gist of it is that you join the wp_posts table with the taxonomy tables a couple times to get the post IDs in your desired category and then join those IDs with the taxonomy tables a couple more times to get the related tags.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 188k
  • Answers 188k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Java SOAP APIs generally assume spec compliance from the service… May 12, 2026 at 5:37 pm
  • Editorial Team
    Editorial Team added an answer public class EditItems<T> : Form where T : IComparable May 12, 2026 at 5:37 pm
  • Editorial Team
    Editorial Team added an answer You cannot attach DOM events to things other than DOM… May 12, 2026 at 5:37 pm

Related Questions

Using Wordpress, I need to generate an array of tags(terms) from posts in a
There seems to be a bug in a Wordpress PHP function that leaves whitespace
I am a systems programmer, so i just know some basic css/html. I like
I run my blog using Wordpress and all too recently became a big believer
I am designing a system for a customer. We are thinking about using Wordpress

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.