Created
January 10, 2020 19:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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