Support

Account

Home Forums Backend Issues (wp-admin) Post Object search by ID or SKU Reply To: Post Object search by ID or SKU

  • Going to be honest, I don’t generally do things like this, all I can do it repeat the examples.

    Basically you add an acf filter for your field

    
    add_filter('acf/fields/post_oject/query/name=YOUR-FIELD_NAME', 'YOUR_FUNCTION_NAME', 10, 3);
    function YOUR_FUNCTION_NAME($args, $field, $post_id) {
      // inside of this filter you add the filters described 
      // for searching post meta
      // as described here and in other places
      // https://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/
      // this is done so that the filters will only be added for
      // this particular field in the admin
      add_filter('posts_join', 'cf_search_join');
      add_filter('posts_where', 'cf_search_where');
      add_filter('posts_distinct', 'cf_search_distinct');
    }
    

    Then you add the other function to search by what you want to search by. You will need to refer to the WC documentation for what field to look at for sku.