Avada WordPress Theme – custom data source for Post Cards

In getting frustrated with needing to get more detailed and specific with the posts being shown in post-cards in certain circumstances, i’ve dug into the code and found a great wordpress filter which can be used to inject your own WP_Query object, instead of using the query generated based on your criteria in the builder.

fusion_post_cards_shortcode_query_override

To use it, you’ll need to use the wordpress ‘add_filter’ method, such as the following;

function my_filter_post_cards($args, $defaults) {
if($defaults['id'] === 'customise-the-query') {
return new WP_Query([
'posts_per_page' => $defaults['number_posts'],
'post_type' => 'suppliers'
]
);
}
}
add_filter( 'fusion_post_cards_shortcode_query_override', 'my_filter_post_cards', 0, 2 );

This lets you really customise the posts shown in the post cards element, rather than being restricted to the options shown in the builder.

Leave a Reply