Skip to content

Instantly share code, notes, and snippets.

@pingram3541
Created January 10, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingram3541/61e1f894a6fd81b7d0c43b753c7bba78 to your computer and use it in GitHub Desktop.
Save pingram3541/61e1f894a6fd81b7d0c43b753c7bba78 to your computer and use it in GitHub Desktop.
Elementor Posts widget change query to more post types instead of just one
/** Showing multiple post types in Posts Widget
* 1) Add "my_custom_filter" or your unique id to your Posts element
* 2) Add the following code to your functions.php making sure to use the same
* unique id that you added to the Posts widget
* 3) Modify the post-types below in the code as needed to match
* the post types you'd desire to use
**/
add_action( 'elementor/query/my_custom_filter', function( $query ) {
// Here we set the query to fetch posts with
// post type of 'custom-post-type1' and 'custom-post-type2'
$query->set( 'post_type', [ 'posts', 'pages', 'some-other-custom-post-type-if-desired' ] );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment