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

  • SEARCH
  • Home
  • 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 7045827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:34:39+00:00 2026-05-28T02:34:39+00:00

In WordPress, I’m trying to run a query to return a postID where it

  • 0

In WordPress, I’m trying to run a query to return a postID where it has been tagged by two (both) ‘tags’. I think I may need a subquery of some sort. Any help appreciated, here;s what I have so far.

SELECT wposts .id
 FROM wp_posts wposts
INNER JOIN wp_term_relationships ON(wposts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON(wp_term_relationships.term_taxonomy_id =wp_term_taxonomy.term_taxonomy_id)
INNER JOIN wp_terms ON(wp_term_taxonomy.term_id = wp_terms.term_id)
WHERE  wposts.post_status = 'publish' AND wposts.post_type = 'header-image' AND wp_term_taxonomy.taxonomy = 'tags' AND ( wp_terms.name ='homepage' AND wp_terms.name ='position1' )
  • 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-28T02:34:40+00:00Added an answer on May 28, 2026 at 2:34 am
    SELECT p .id
    
    FROM wp_posts AS p
      INNER JOIN wp_term_relationships AS rel1
        ON p.ID = rel1.object_id
      INNER JOIN wp_term_taxonomy AS tax1 
        ON rel1.term_taxonomy_id = tax1.term_taxonomy_id
      INNER JOIN wp_terms AS term1 
        ON tax1.term_id = term1.term_id
    
      INNER JOIN wp_term_relationships AS rel2
        ON p.ID = rel2.object_id
      INNER JOIN wp_term_taxonomy AS tax2 
        ON rel2.term_taxonomy_id = tax2.term_taxonomy_id
      INNER JOIN wp_terms AS term2 
        ON tax2.term_id = term2.term_id
    
    WHERE p.post_status = 'publish' 
      AND p.post_type = 'header-image' 
      AND tax1.taxonomy = 'tags' 
      AND term1.name ='homepage'
      AND tax2.taxonomy = 'tags'  
      AND term2.name ='position1' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

WordPress has been installed as a blog into osCommerce. I'm trying to get the
A WordPress website we are running for a client has been comprimised and are
WordPress has this thing that examines whether it has been set up (installed) on
My wordpress site has been hacked. Through this program: http://sitecheck.sucuri.net/ (...) i found that
Wordpress ships with the wpdb class which handles CRUD operations. The two methods of
Wordpress has a filter that automatically add paragraphs to posts. I can remove this
A wordpress theme I'm working on has headlines which span across the entire content
WordPress requires you give each blog post at least two fields: a title and
In Wordpress I'm trying to enqueue a script for a jQuery gallery only for
Wordpress has a spam filtering plugin called Akismet that seems to be able to

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.