• Resolved Jethro99

    (@jethro99)


    I’m trying to exclude Posts that are under category “Multi-Family”. Users can choose home plans and drill down as to # of beds, # bath, foundation, etc. All that works fine. The problem is that users want to choose between Single Family and Multi-Family. There is no category for Single Family. So, to get only the Single Family content, I have to exclude “Multi-Family”. Here is my code for doing that – but it does not work – can anyone tell me why – or point me in the right direction – I am new to WordPress:

    $dwelling_option gets its setting from <option><option> in another php file which does work. There is one other PHP file, but it is for display only.

    //Dwelling Type

    if ( (!empty($dwelling_options)) AND (!empty($dwelling_options )) )
    {
    $filter_flag = true;
    $keyss = ”;
    if(count($post_ids_meta) > 0) {
    foreach($post_ids_meta as $val) {
    $keyss .= $val.’,’;
    }
    $keyss = trim($keyss , “,”);
    }
    if(!empty($keyss)) {

    $post_ids_meta = $wpdb->get_col( $wpdb->prepare( ” SELECT DISTINCT wp_posts.ID FROM wp_posts
    LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
    LEFT JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
    WHERE wp_term_taxonomy.taxonomy = ‘category’
    AND wp_term_relationships.term_taxonomy_id != 108
    AND wp_term_taxonomy.term_id = “.$dwelling_options.”
    AND wp_posts.post_status = ‘publish’
    AND wp_posts.post_id IN (“.$keyss.”) “));
    }
    else {
    $post_ids_meta = $wpdb->get_col( $wpdb->prepare( ” SELECT DISTINCT wp_posts.ID FROM wp_posts
    LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
    LEFT JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
    WHERE wp_term_taxonomy.taxonomy = ‘category’
    AND wp_term_taxonomy.term_id = “.$dwelling_options.”
    AND wp_posts.post_status = ‘publish’ “) );
    }
    }

    Appreciate your help

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator James Huff

    (@macmanx)

    There isn’t any “advanced search” in WordPress standard.

    What plugin are you using to provide this functionality, or is it built into your theme, and if so what is the name of your theme and where did you get it from?

    Thread Starter Jethro99

    (@jethro99)

    THANKS for your quick response

    Sorry, let me clarify, this is a custom theme. I was told it was developed by guys in India. And the Search looks like it is from a real estate Advance Search – but there is no plugin – you can see it at:

    http://www.nelsondesigngroup.com/?page_id=3224

    I’ve added the drop down for dwelling – and the code to exclude multi-family – but it does not work. It still includes both single and multi-family.

    The PHP page is advancedsearch.php – this runs the search/sort through the DB

    advanced-search.php – this displays the page you see on the website

    options_dwelling.php (et el) individual <option><option> for dropdowns.

    THANKS!

    Moderator James Huff

    (@macmanx)

    Ah, ok, it’s probably part of the theme then.

    We really can’t support custom themes here to that extent. Have you reached out to the folks who made it for you?

    Thread Starter Jethro99

    (@jethro99)

    As I said they are in India. This site was done several years ago and I’ve only been on the job a few months. What I really need is to just exclude Multi-Family from the search of posts. What would be the best way to do this? I see in the codex something like this: Is this a start? What would come next?

    $args = array(

    ‘posts_per_page’ => -1,

    ‘category’ => ‘-108’,

    ‘post_type’ => ‘post’,

    ‘post_status’ => ‘publish’,

    );

    THANKS again

    Moderator James Huff

    (@macmanx)

    As I said they are in India.

    Ok, but I’m not sure what that has to do with it. I work with people in India on a daily basis via email, chat, sometimes phone. Are you saying you have absolutely no way of contacting them?

    What I really need is to just exclude Multi-Family from the search of posts. What would be the best way to do this?

    Since the search was built custom, the best way would be to contact whomever built it, or hire a new person to build it more to your liking.

    Custom code is, well, custom, and that makes it rather difficult to support here for free without a lot of back-and-forth.

    Thread Starter Jethro99

    (@jethro99)

    Ok thanks – I appreciate your time.

    No I have no way of contacting the original programmers. Can you make a recommendation of someone that can help me? I don’t have a lot of $$ but I really need to learn wordpress as well as build a new custom server and don’t have a lot of time. I know PHP, HTML, mysql, css. Just need to get through the bumps like this.

    Moderator James Huff

    (@macmanx)

    Please try http://jobs.wordpress.net/ or http://directory.codepoet.com/ and do not accept any hire offers posted to these forums.

    Thread Starter Jethro99

    (@jethro99)

    THANKS!!

    Moderator James Huff

    (@macmanx)

    You’re welcome!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Exclude posts on advanced search’ is closed to new replies.