-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add the ability set a WordPress filter on the posts query arguments #18
Comments
Hi guys, I need some help, im there but not :-) I'm trying to do this: I need to filter posts - first if defined by Category xxx, yyy, zzz - if not defined in the shortcode then all Categories but only those that have a defined TAG -or TAGS in the shortcode. Then on filter change to category yyy - have just those that are in Category yyy and have the TAG or TAGS defined Ex: Categories: Boston, Texas, New York ... Show all posts with TAG = Spotlights and in categories Texas, New York ( if no Categories defined in the shorcode take all ) |
@andreacreativesoft As discussed in the mail I can look next week at this. But feel free to create a pull request or fork the project if you need that functionality this week. The initial query and the filtered queries all pass through this function: https://github.com/Robbertdk/wordpress-ajax-filter-posts/blob/master/class-ajax-filter-posts.php#L280 See also the docs to create nested taxonomy queries: https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters |
Thanks, I manage to get the listing OK, but somehow I lose the tag once the
category filter is selected :-(
maybe we can collaborate on this or in the future - outsource - but I
assume at your level work is not a problem :-)
*Kind Regards*,
I.C. Andrea
*Andrea Creative Soft Design*
*skype*: andrea_ifrim
*e*: andreacreativesoft@gmail.com
…On Tue, 9 Mar 2021 at 21:39, Robbert de Kuiper ***@***.***> wrote:
@andreacreativesoft <https://github.com/andreacreativesoft> As discussed
in the mail I can look next week at this.
But feel free to create a pull request or fork the project if you need
that functionality this week.
The initial query and the filtered queries all pass through this function:
https://github.com/Robbertdk/wordpress-ajax-filter-posts/blob/master/class-ajax-filter-posts.php#L280
You can combine the given $args with the specific arguments you want to
alter the query.
See also the docs to create nested taxonomy queries:
https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASMWZNHU6JF4ARDPW5UCOWTTCZ2QPANCNFSM4YYHWJYA>
.
|
@andreacreativesoft Can you show the code changes you've made? Then I can take a quick look at it. |
I just changed this:
public function create_shortcode($atts) {
$attributes = shortcode_atts( array(
'post_type' => 'post',
'tax' => ['post_tag'],
'posts_per_page' => 12,
'multiselect' => 'true',
'tags' => ['post_tags']
), $atts, $this->plugin_name );
$filterlists = $this->get_filterlist($attributes['tax']);
$query = new WP_Query([
'post_type' => $attributes['post_type'],
'posts_per_page' => $attributes['posts_per_page'],
'order' => 'DESC',
'post_status' => 'publish',
'tag__in' => $attributes['tags'],
]);
*Kind Regards*,
I.C. Andrea
*Andrea Creative Soft Design*
*skype*: andrea_ifrim
*e*: ***@***.***
…On Tue, 9 Mar 2021 at 21:39, Robbert de Kuiper ***@***.***> wrote:
@andreacreativesoft <https://github.com/andreacreativesoft> As discussed
in the mail I can look next week at this.
But feel free to create a pull request or fork the project if you need
that functionality this week.
The initial query and the filtered queries all pass through this function:
https://github.com/Robbertdk/wordpress-ajax-filter-posts/blob/master/class-ajax-filter-posts.php#L280
You can combine the given $args with the specific arguments you want to
alter the query.
See also the docs to create nested taxonomy queries:
https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASMWZNHU6JF4ARDPW5UCOWTTCZ2QPANCNFSM4YYHWJYA>
.
|
…Issue #18 Add a wrapper function for WP_Query calls with the filter ajax_filter_posts_query_args so developers can alter the quries
@andreacreativesoft I've added a filter hook to allow developers to alter the query. See the example in the Readme to use that filter hook for adding a extra term to the query https://github.com/Robbertdk/wordpress-ajax-filter-posts#query-arugments |
The question, there is no way to implement the TAG in my case in the
shortcode?
Manage to make it work with the new change which is great but I don't see
how I can define the same shortcode to
use different TAGS cause on one page I need them by TAG xxx on another by
TAG yyy
*Kind Regards*,
I.C. Andrea
*Andrea Creative Soft Design*
*skype*: andrea_ifrim
*e*: ***@***.***
…On Sun, 14 Mar 2021 at 23:08, Robbert de Kuiper ***@***.***> wrote:
Closed #18
<#18>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASMWZND32I5I3YVS6VQ3SADTDUQWRANCNFSM4YYHWJYA>
.
|
@andreacreativesoft I've added the option to pass an id as an attribute to your shortcode, which you can get in your filters hooks. With that you can decide how to alter your queries by the given id. See #23 for an example |
This creates the capability of a developer set extra arguments on the initial query and the queries with the activated filters.
For example to add specific ordering, pagination or other tax query arguments.
The text was updated successfully, but these errors were encountered: