Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRO filter request] - Ability to override the post widgets wp_query with the global passed on archive pages etc #2109

Closed
kiwiot opened this issue Jul 31, 2017 · 5 comments
Labels
theme-builder References any component related to Elementor Pro’s Theme Builder.

Comments

@kiwiot
Copy link

kiwiot commented Jul 31, 2017

I have spent the afternon trying to find an elegant solution to the fact that there is no nice way to display category, archive and search pages in a way that mimics the post widget due to the fact that the WP_Query call is not dynamic in anyway.

For now here is my work around and also a filter request to be added to the PRO version.

  1. Save the specific post styles etc into the elementor library
  2. add the shortcode of this to the archive.php or any other taxonomy page etc

Right now this will just display all the posts as the widget is stil calling the same static wp_query.

My solution is to add a filter to the following file

/plugins/elementor-pro/modules/posts/widgets/posts.php lines 64-66

public function get_query() {
	return apply_filters('override_query', $this->query);
}

Not the most elegant solution but this does allow me to then alter the query for the archive page as I see fit - in my case I am overriding the elementor query to load in the original global query which includes the tax_query and search as well

Like so

add_filter('override_query', array( $this, 'elementor_posts_override_query'));

public function elementor_posts_override_query( $elementor_query ) {

	global $wp_query;

	if ( is_main_query() && (is_category() || is_archive() || is_search() )) {
		return $wp_query;
	} else {
		return $elementor_query;
	}
}

I am totally open to other methods to achieve this behaviour but from all my digging through the core code there seems to be zero ability to extend or override the current query in a way that makes it dynamic.

@arielk arielk added the product/pro Indicates if the referenced component is part of the Elementor Pro plugin. label Aug 3, 2017
@ghost
Copy link

ghost commented Aug 22, 2017

I don't want to get into editing PHP or the theme files, so I'd like to see a way of applying Elementor layouts to the Archive and Category WP templates.
To me the whole purpose of Elementor is to avoid editing the code ... I've never been able to master that.

@sododesign
Copy link

Hi @arielk, some progress in this? It would be very useful for developers.

@bainternet bainternet added the theme-builder References any component related to Elementor Pro’s Theme Builder. label Nov 12, 2017
@bainternet
Copy link
Contributor

@sododesign

We do have some progress on this but nothing ready yet.
We keep this issue open to follow up and will close it once we release the solution we have come up with.

@arielk arielk removed the product/pro Indicates if the referenced component is part of the Elementor Pro plugin. label Jan 21, 2018
@jokr0815
Copy link

Hi @bainternet,

any update on this topic?
We woul like to present various/different CPTs within the posts widget as well or is there another solution for this already?

Thanks and kind regards
Jo

@bainternet
Copy link
Contributor

closing in favore of #3826

thanks everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme-builder References any component related to Elementor Pro’s Theme Builder.
Projects
None yet
Development

No branches or pull requests

5 participants