Results 1 to 1 of 1

Thread: How to get all the posts whose have pictures

  1. #1
    Thread Starter
    Junior Member mehdicherfi's Avatar
    Join Date
    Mar 2012
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get all the posts whose have pictures

    Hi

    Does someone know how I can refine result on picture post ?
    I would like to get all the posts (ads) where there is at less 1 picture.

    Here is my SQL request I use to get ads (refine search)
    HTML Code:
    SELECT * FROM wp_posts
     INNER JOIN wp_postmeta AS m ON (wp_posts.ID = m.post_id) 
     INNER JOIN wp_terms AS t ON x.term_id = t.term_id 
     INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)  
     INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id) 
     INNER JOIN wp_postmeta AS mt3 ON (wp_posts.ID = mt3.post_id)
    WHERE (((wp_posts.post_title LIKE '%%'))) 
     AND (wp_posts.post_status = 'publish') 
     AND (wp_posts.post_type IN ('ad_listing')) 
     AND ((mt1.meta_key = 'cp_price') AND (CAST(mt1.meta_value AS SIGNED) BETWEEN '2500' AND '17200')) 
     AND ((mt2.meta_key = 'cp_kilomtrage') AND (CAST(mt2.meta_value AS SIGNED) BETWEEN '2500km' AND '150000km'))
    But the problem is that in my database the ad is split in serveral post (1 with the content, 1 with with the picture ) and I don't know the SQL request which permit to do that.

    The previous SQL request find the post where post_status = 'publish' and post_type IN ('ad_listing') althought for the post with the picture values are inherit and attachment.

    Can you help me?

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Only able to show 2 pictures per ad
    By ajomalley in forum Report ClassiPress Bugs
    Replies: 6
    Last Post: October 14th, 2011, 04:21 AM
  2. Replies: 3
    Last Post: November 30th, 2010, 06:43 AM
  3. [SOLVED] add text to posts - "click to enlarge pictures"
    By epreneur in forum ClassiPress General Discussion
    Replies: 4
    Last Post: September 18th, 2010, 09:43 AM
  4. Blog Posts vs. Ad Listing Posts?@!%?
    By pruittdee in forum Report ClassiPress Bugs
    Replies: 10
    Last Post: April 17th, 2010, 05:17 AM