Jump to content

Pull post from a specific Wordpress category


mccrum
 Share

Recommended Posts

Hi, im looking to pull 3 posts from a specific Wordpress Category. At the minute I can pull 3 latest posts and display them in a flash banner using the code below.

 

SELECT yah_posts.*, yah_postmeta.* 
FROM yah_posts 
LEFT JOIN yah_postmeta ON yah_posts.ID = yah_postmeta.post_id 
WHERE yah_postmeta.meta_key = 'largeimage' && yah_posts.post_status = 'publish' 
ORDER BY post_date DESC LIMIT 3

 

I want to be able to pull 3 latest posts from a specific category instead of just 3 latest posts from every category.

 

I have put together this code below, but it doesn't seem to be working :(

 

$query = "SELECT yah_posts.*, yah_postmeta.* 
FROM yah_posts 
LEFT JOIN yah_postmeta ON yah_posts.ID = yah_postmeta.post_id 
AND LEFT JOIN $yah_term_taxonomy ON($yah_term_relationships.term_taxonomy_id = $yah_term_taxonomy.term_taxonomy_id) 
WHERE yah_postmeta.meta_key = 'largeimage' && yah_posts.post_status = 'publish' 
AND $yah_term_taxonomy.term_id = '1' 
AND $yah_term_taxonomy.taxonomy = 'category' 
ORDER BY post_date DESC LIMIT 3";

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.