A
A
Alexander Bondarenko2021-06-26 14:47:46
WordPress
Alexander Bondarenko, 2021-06-26 14:47:46

How to get products in the name of which there is a string?

I get products in this way, but sorting by name does not work, by category of the day and the set works, how can I fix the search by name?

$query = new WP_Query( [
    'post_type'      => 'product',
    'post_status'    => 'publish',
    'posts_per_page' => -1,
    'tax_query' => [
    'relation' => 'AND',
      [
        'name__like'=> $product_name,
      ],
      [
        'taxonomy' => 'product_cat',
        'field'    => 'slug',
        'terms'    => array('nabor'),
      ],
      [
        'taxonomy' => 'product_cat',
        'field'    => 'slug',
        'terms'    => $day,
      ],
  ]
] );

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question