Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter mikegarlick

    (@mikegarlick)

    I have fixed the issue. I had forgotten that I had de-registered the adding of jQuery in my functions file but I had also de-registered the livequery script too with:

    wp_deregister_script( 'livequery' );

    I have removed that line and the variations now work normally.

    Hope this helps anyone with the same/similar issue.

    Thread Starter mikegarlick

    (@mikegarlick)

    After a hell of a lot of searching I manages to find the following code which works perfectly once pasted into the functions.php file.

    function atom_search_where($where){
      global $wpdb;
      if (is_search())
        $where .= "OR (t.name LIKE '%".get_search_query()."%' AND {$wpdb->posts}.post_status = 'publish')";
      return $where;
    }
    
    function atom_search_join($join){
      global $wpdb;
      if (is_search())
        $join .= "LEFT JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id";
      return $join;
    }
    
    function atom_search_groupby($groupby){
      global $wpdb;
    
      // we need to group on post ID
      $groupby_id = "{$wpdb->posts}.ID";
      if(!is_search() || strpos($groupby, $groupby_id) !== false) return $groupby;
    
      // groupby was empty, use ours
      if(!strlen(trim($groupby))) return $groupby_id;
    
      // wasn't empty, append ours
      return $groupby.", ".$groupby_id;
    }
    
    add_filter('posts_where','atom_search_where');
    add_filter('posts_join', 'atom_search_join');
    add_filter('posts_groupby', 'atom_search_groupby');

    Brilliant! thank you for the reply. I’ll let you know how i get on!

    I am looking to do something similar.

    I want to be able to filter a custom post post type with the details provided in the xprofile. The problem i have is that the data field i want to search by has many things in them.

    What im making is a custom post type of jobs advertised on the site and when they get to the site i nead to search the posts custom fields or tags with the xprofile data field.

    I hope that makes sense

    Thread Starter mikegarlick

    (@mikegarlick)

    thanks for your input jibbius ??

    It means re-jigging my tables and initial INSERT sql but yeah thats probably the best way forward using the ID.

    Thread Starter mikegarlick

    (@mikegarlick)

    I have since removed the * after the DELETE as I was informed thats not allowed but still no joy. it just doesn’t do anything (to the table/rows).

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