Is it possible to have a query loop with several post types, and different cards based on the post type? Or do I need something like wpgridbuilder for that?
Found a way:
<?php
function get_loop_item_post_type() {
$posttype = \Bricks\Query::get_loop_object();
return $posttype->post_type;
}
And in the conditions:
Is this the correct way to do it?
1 Like
I think you’ll want to use data-attributes in order to do css styling or something like that. Conditions shows or hides content, so this will basically only show posts that are services in your case.
On the ‘Posts card wrapper’ I did the same condition but with ‘post’.
I think if the cards are a lot different this could work nicely.
But if there are only some elements in design, how would you do it with the data-attributes?
Thanks @wotimama , this is exactly what I needed.
Just had to remember to add the custom function to the bricks filter, so for anyone else looking at this option, this is what I set up:
function get_loop_item_post_type() {
$posttype = \Bricks\Query::get_loop_object();
return $posttype->post_type;
}
add_filter('bricks/code/echo_function_names', function() {
return[
'get_loop_item_post_type',
];
});
Then you can use the echo function in the conditions.
1 Like