elementor / elementor

The most advanced frontend drag & drop page builder. Create high-end, pixel perfect websites at record speeds. Any theme, any page, any design.
https://elementor.com/
GNU General Public License v3.0
6.57k stars 1.41k forks source link

Landing Page - adjust_landing_page_query overwrites existing post_type query-var #17379

Open dhavalgshah opened 2 years ago

dhavalgshah commented 2 years ago

adjust_landing_page_query function uses pre_get_posts action to add its post type to query-vars. However, it doesn't check for existing values and overwrites them. Thus causing conflicts with other plugins/themes.

https://github.com/elementor/elementor/blob/bd8b98c3aa39570e20e75021e7fafaf926bafbc4/modules/landing-pages/module.php#L343

The above line should be:

// Create the post types property as an array and include out CPTs in it.
$query_post_types = $query->get( 'post_type');
$query_post_types[] =  self::CPT;
erikjandelange commented 2 years ago

To keep it in on one line it alsow can be done by:

$query_post_types = array_merge( $query->get('post_type'), [self::CPT] );