W
W
WQP2016-09-29 15:10:31
WordPress
WQP, 2016-09-29 15:10:31

How to specify an additional field in WP_Query?

Hello, you need to make a request in WP_Query for an additional field in which the array.
Request

$id = 3;
$param = array(
    'post_type'      => 'courses',
    'order'             => 'DESC',
    'posts_per_page' => -1,
    'meta_query' => array(
    array(
      'key'     => 'teachers',
      'value'   => $id,
      'compare' => 'LIKE',
    ),
  ),
);

It is not clear what array should be in meta_query. Additional field teachers contains an array
[0] => Array
        (
            [ID] => 3
            [user_firstname] => Владимир
            ....
),
[1] => Array
        (
            [ID] => 4
            [user_firstname] => Александр
            ....
)

And you need to compare them by ID and output

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zakaz_zakaz, 2016-09-29
@Zakaz_zakaz

This will not work.
You need to display all the values ​​\u200b\u200bof "courses", and then do foreach array meta and check the ID.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question