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 818503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:09:49+00:00 2026-05-15T02:09:49+00:00

At present I am displaying a list of the last 5 posts in a

  • 0

At present I am displaying a list of the last 5 posts in a site’s blog in its footer using this mysql query:

SELECT post_title, guid, post_date FROM wp_posts WHERE post_type = 'post' AND post_status = 'Publish' ORDER BY post_date DESC LIMIT 5

How can I edit this query to restrict the search to a particular category id? I thought it would be as simple as looking for a category field in the posts table but it isn’t!

  • 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-15T02:09:50+00:00Added an answer on May 15, 2026 at 2:09 am

    The relations of the WordPress database is available in the database diagram.

    In your particular case it is:

    wp_posts.ID
    ->wp_term_relationships.object_id
    ->wp_term_relationships.term_taxonomy_id
    ->wp_term_taxonomy.term_taxonomy_id
    ->wp_term_taxonomy.term_id
    ->wp_terms.term_id

    For querying you need to use an SQL join:

    SELECT p.ID, t.term_id
    FROM wp_posts p
    LEFT JOIN wp_term_relationships rel ON rel.object_id = p.ID
    LEFT JOIN wp_term_taxonomy tax ON tax.term_taxonomy_id = rel.term_taxonomy_id
    LEFT JOIN wp_terms t ON t.term_id = tax.term_id
    

    But it should be noted that the wordpress database might change at any time, and you should use the WordPress provided mechanisms (such as query_posts) to filter posts from the database.

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

Sidebar

Related Questions

I have this code which i am using to present my data in a
I am facing a problem displaying the result of my select * query on
I've a UITableViewController which has Edit/Save and cancel buttons. At present I'm displaying 5
At present I'm having to do something like this to build a Type definition
I present the view controller like this: FBViewController *fbViewController =[[FBViewController alloc] initWithNibName:@FBViewController bundle:nil]; fbViewController.label.text=@hello;
How do I output timezone offsets based on the list of regions present in
I have an android spinner that's populated by a list of strings using an
I tried posting this on the Android Developers list and didn't hear anything -
Urgh, I have spent the last couple of hours on this now. I normally
I'm displaying a list of <dl> tags tags in my page. I'd like for

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.