Home › Toolset Professional Support › [Resolved] Unable to use Block Editor for Views
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Tagged: Toolset Blocks
This topic contains 39 replies, has 2 voices.
Last updated by GinaM9227 4 years, 8 months ago.
Assisted by: Minesh.
> I already shared a test page that holds the Block view which is created by following the steps I already mentioned.
Yes and I used your test page and created a View for Products - See here: hidden link
Next, I want to be able to use Query Filter to especify which products I want to show. I need to exclude some products from the list.
- How do I use Query Filter together with the Blocks page you created? I have the Query settings that I need but it's on the old Classic Editor.
Once you click on your block view on the test page:
=> hidden link
On the right sidebar, you will see the option Search to activate the search on your view, which you need to activate and once you activate it, it will add search section on your block view and using the button "Add Search field" you can add as many frontend filters as you want. Please check the following screenshot:
=> hidden link
Please check the following video that shows how you can add the search filters:
=> hidden link
Thank you. I looked at the video and it's not quiet what I'm looking to do. I need to create a view that excludes certain items but I do not want users to be able to search.
For example: In the view that I want to create, I would exclude all Products older than a certain date and exclude all Products that are not of the Ticket Taxonomy.
What I don't want is for Users to be able to search..the View should just be presented.
That means you just need to add Query filters to your view and you do not want to present the forntend filters.
You can simply add your query filters from the Query filter section. Once you select your view block on the right side you will see the Query Filter tab from where you can add your query filters to filter your view. Please check the following screenshot:
=> hidden link
You can add whatever query filters as per your requirement.
I added the Query Filters but cannot get it to work.
1) Show product-type = ticket-event
2) Show Dates equal to or Later than Today
See attached
"product_type" is the hidden taxonomy used by WooCommerce to store the product type. You need to use view's hook wpv_filter_query in order to query the simple products.
For example - please add following code to your current theme's functions.php file or "Custom Code" section offered by Toolset.
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
add_filter( 'wpv_filter_query', 'func_filter_ticket_products', 101, 3 ); function func_filter_ticket_products( $query_args, $view_settings, $view_id ) { if ( $view_id == 3313) { $query_args['tax_query'] = array( array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => array('ticket-event'), 'operator' => 'IN' ) } return $query_args; }
I found this documentation which advises to use the Date filter as a Number - I did that and now the Views is not showing any products..
https://toolset.com/documentation/user-guides/views/date-filters/
The _start_date_picker is not a Types field so you should keep using Date. I've already adjusted the field.
And you can apply the code I shared to filter with your product_type. I hope that is enough now.
I fixed the Functions.php using your code and was going to edit the Query Filter in the Views but something happened and I cannot log to Admin..see attached
maybe it's the code?
Here is the error message:
An error of type E_PARSE was caused in line 335 of the file /home/congenia/public_html/wp-content/themes/oceang/functions.php. Error message: syntax error, unexpected '}', expecting ')'
There must be an error in the code
ahh, silly error. semicolor was missing.
Please try to use the following code:
add_filter( 'wpv_filter_query', 'func_filter_ticket_products', 101, 3 ); function func_filter_ticket_products( $query_args, $view_settings, $view_id ) { if ( $view_id == 3313) { $query_args['tax_query'] = array( array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => array('ticket-event'), 'operator' => 'IN' )); } return $query_args; }
Attached is the new Query Filter -
However, No products are showing on the Preview..
Ok I see the code I shared applied successfully.
Now, I see two event start dates. Which event start date you are referring to? the Start date available with woocommerce General settings or the custom field you created?
The Query Filter for product type does not seem to work since it is still returning non Ticket items - see attached.
To apply the product type filter you do not need to add the query filter (so I removed it). The code I shared is enough to apply the the product_type filter.
Now, if you check the membership post: hidden link
- The post is set to Event Ticket that is why its displaying.