Use dynamic data from another query?

Is it possible to get the query results from another object? I have been looking but I can’t find anything. I want to use this information in a block that’s not from inside the Query loop. Any tips? In particular, I’m trying to get a text field (name) from a slideshow query to use elsewhere.

You can nest queries. If you only want the text-field from one perticular post in all of your quer-results, then create another query inside it, with only this post selected.

Does this help?

Cheers Suat

Sadly not :frowning: The element I’m trying to use the data in is in a totally isolated block from where the query is, not nested inside of it.

You could try the query editor and use the result from one query as the parameter for another query.

Oh interesting- how would I grab the original query?

Hi

the concept is that you create a query in the query editor and then use the results of this first query as the parameters for the second query that Bricks will use via the return args.

Below is an example of such a setup in the query editor that I use on my page.

My example is more complicated than a simple query as I first read data from an ACF options page which I then have to prepare for the first query, but you can see the concept how it works.

$abigchef = get_field('abigchef_anmeldung', 49037);
$value_array = explode(",", $abigchef);

 $meta_query["relation"] = "OR";
            foreach ($value_array as $chef) {
                $meta_query[] = [
                    "key" => "choch_vorname",
                    "value" => strtolower($chef),
                    "compare" => "LIKE",
                ];
            }
 
   $value_array = explode(",", $abigchef);
       
         foreach ($value_array as $koepfe) {
         $args = array(
         'post_type'        => 'obersee-choch',
         'posts_per_page'   => -1,
          'meta_query' => [
         [
         'key' => 'choch_vorname',
         'value' =>  strtolower($koepfe)
         ]
         ]
         );
         $the_query = new WP_Query( $args );
         if ( $the_query->have_posts() ) {
         
    while ( $the_query->have_posts() ) : $the_query->the_post();
    $meta[$ct] = array(
    "key" => "chochete_abigchef-relation",
    "value" => get_the_id(),  // works for int-array
    "compare" => "LIKE"
    );
    $ct = $ct + 1;
    endwhile;
    }
    $meta["relation"] = "OR";
         }
return [
  "post_type" => "chochete",
                "posts_per_page" => -1,
                "orderby" => "title",
                "order" => "ASC",
                "meta_query" => $meta,
];

Cheers

Patric