0

I need to use Posts element to display posts from two post types. Since I have to select a source, I've selected Post, but then my custom query can't override this.

Following the first example from these instructions https://developers.elementor.com/docs/hooks/custom-query-filter/, I've added this code to functions.php, but with no effect. When I override posts_per_page or something else, that works, but 'post-type' does not.

enter image description here

add_action( 'elementor/query/latest-posts-home', function ( $query ) {
    $query->set('post-type', array('alicorn_case_studies', 'post'));
});

1 Answer 1

2

Fixing a small typo should be it (untested):

add_action( 'elementor/query/latest-posts-home', function ( $query ) {
    $query->set( 'post_type', array( 'alicorn_case_studies', 'post' ) );
} );

The parameter post-type should be post_type.

1
  • 1
    Thank you! Can't believe I overlooked this this. Jun 8, 2023 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.