A
A
Alexander Sharomet2018-05-17 16:42:34
WordPress
Alexander Sharomet, 2018-05-17 16:42:34

How to display all posts using carbon fields using carbon fields?

Hello.
How can I display all posts where the carbon fields plugin is used?
I created custom fields:

Container::make('post_meta', 'Настройки продукта')
    -> show_on_template('product-template.php')
    -> add_fields(array(
      Field::make('text', 'price_field', 'Цена') -> set_width(50),
       	Field::make('textarea', 'price_short_description', 'Краткое описание'),
    ));

And now I want to display all posts where I use these custom fields and don't know how to do it.
You can only display one product this way.
$products = carbon_get_post_meta( $id, $name );
var_dump($products);

But what if I need everything?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sharomet, 2018-05-18
@sharomet

If anyone is interested:

$query = new WP_Query(array(
      'post_type' => 'post',
      'meta_query' => array(
        array(
          'key' => 'price_field',
        ),
      ),
    ));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question