Results 1 to 1 of 1

Thread: How to fetch ads based on custom fields.

  1. #1
    Thread Starter
    newnetsoftware's Avatar
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to fetch ads based on custom fields.

    I created the custom field "cp_job". Each ad has a value for "cp_job", which is either "Buyer" or "Seller"

    Trying to figure out how to change the classipress queries is too time consuming

    How do i change the below query to fetch ads where cp_job='Buyer'

    I tried this but no results are being returned.


    Code:
    <?php
    // Query Args
    $args = array(
        'meta_key' => 'cp_job',
        'meta_value' => 'Buyer'
    );
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    if ( $the_query->have_posts() ) {
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            // Do things with the post data
        }
    } else {
        // no posts found
    }
    /* Restore original Post Data */
    wp_reset_postdata();

    Does the above query even connect to the mysql database?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combing Advanced Custom Fields with Vantage to search custom fields
    By rapidweb in forum Vantage General Discussion (Legacy)
    Replies: 8
    Last Post: August 12th, 2014, 02:20 AM
  2. Combing Advanced Custom Fields with Vantage to search custom fields
    By rapidweb in forum Help Using Vantage (Legacy)
    Replies: 3
    Last Post: June 7th, 2013, 12:18 PM
  3. Custom Fields Region Drop Down based on Location Drop Down - Classipress
    By fuzegraphics in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: March 25th, 2012, 01:25 PM