Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to link specific columns from a few standard tables in a wordpress database. I specifically want to see a view/table that includes:

post title
post content
guid
meta value = image url

This kind of works but I have 3 rows per item returned. I just want one, then to be able to select the newest item from all categories except 2, 4 and 7 for example.

SELECT wp_posts.post_title, wp_posts.`guid`, wp_postmeta.meta_value
FROM wp_posts, wp_postmeta
WHERE wp_posts.post_type = 'post'
AND wp_postmeta.meta_key = 'image_url'
AND wp_posts.post_status = 'publish'

I've been on this task for 3 days and searched hi and lo, watched videos, followed tuts and am about to pull my hair out.

share|improve this question
add comment

1 Answer

I think this could be life saver for you . This is a simple function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.

<?php $posts_array = get_posts( $args ); ?>




<?php $args = array(
    'numberposts'     => 5,
    'offset'          => 0,
    'category'        => ,
    'orderby'         => 'post_date',
    'order'           => 'DESC',
    'include'         => ,
    'exclude'         => ,
    'meta_key'        => ,
    'meta_value'      => ,
    'post_type'       => 'post',
    'post_mime_type'  => ,
    'post_parent'     => ,
    'post_status'     => 'publish' ); ?>

for exclude categories try adding a minus sign in front of category id.

share|improve this answer
    
hey thanks there, but thats the php side of it (which i hate) and dreamweaver took care of that for me. i was hoping to cover it in sql ?) –  user1067011 Nov 26 '11 at 20:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.