I tried using the query_args filter, but nothing was displayed at all:
function layout_query_args( $args ) {
$args = array(
'post_type' => 'Institutions',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'country_bd',
'value' => 'my-val',
'compare' => '='
),
array(
'key' => 'country_bd',
'value' => '',
'compare' => '!='
)
)
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : ?>
<ul>
<h2>
<?php $key; ?>
</h2>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li id="post-<?php the_ID(); ?>">
</li>
<?php
endwhile;
wp_reset_postdata(); ?>
</ul>
<?php endif;
}
add_filter( 'custom-layouts/layout/query_args', 'layout_query_args', 10 );
Hey @atoyansk
That code looks a little off.
Lets try to look at the issue another way (I hope I understood it correctly).
Why don’t we create 3 seperate layouts, and for each one, restrict them to a specific country?
If that sounds like what you are trying to do, or would work, then I can help with the logic to set that up.
The other question would be, how are you creating layouts, via the block editor, or via our admin pages?
Thanks
-
This reply was modified 4 years, 3 months ago by
Code Amp.