Views plugin lets you build your own custom search for any content type. These searches can be based on post content, taxonomies and custom fields.
When you ask for help or report issues, make sure to tell us settings for your custom search.
Viewing 15 topics - 346 through 360 (of 754 total)
Problem: I have a View of custom posts that displays a map with markers, using a distance filter and sorting results by distance. In some cases the distance center is set by a URL parameter, and in others, it is set by a shortcode attribute. I have implemented some custom code in a wpv_view_settings filter to toggle between the shortcode attribute and the URL parameter. In the cases where distance center is set by a shortcode attribute, I am using another custom shortcode to get the User's predicted zip code. That shortcodes an external service to get a predicted zip code based on the User's IP address. The custom zip code service seems to be working correctly, and the results of the View seem to be accurate.
However, in the cases where this zip code shortcode is used to set the View's distance Query Filter by shortcode attribute, the View consistently causes the page generation time to jump by 3 or more seconds. I would like to try to optimize the page load time as much as possible.
Solution: In this case, testing revealed that using the custom zip shortcode inside a wpv_view_settings filter callback was the source of the delay in page generation, for some reason not fully understood. Replacing that shortcode with a hard-coded zip code resulted in a page generation time just a fraction of a second higher than the page without the View present at all.
Optimization of the zip code shortcode is necessary to prevent the latency seen in page generation time.
Problem: If no items are found in a View of WooCommerce Orders, I would like to automatically refresh the View results after a set amount of time.
Solution: There is no automatic feature for refreshing View results, nor is there a true JavaScript API for Views, but you could achieve something similar by reloading the current page in a setTimeout function added to a script tag in the wpv-no-items-found block of the View, for example:
This will reload the current page after 5 seconds if no results are found in the View. That loop of refreshing every 5 seconds would continue until results exist.
Problem:
The user would like to filter a view using a taxonomy assigned to the parent post in a Toolset relationship.
Solution:
Actually, this is not possible. Toolset does not offer a way to filter a custom post type by the custom fields or taxonomies from a related post type. You can only filter with:
- The post's default(title, content, date, etc.) and custom fields.
- The post's taxonomies.
- ONE related post type in a Toolset relationship.
As a workaround, I'll suggest syncing the taxonomy from the parent post to the child posts. You can add a custom code, hooked to the save_post action, use the relationship API inside of it to synchronize the taxonomy assignment to the child posts.
Problem:
The user has a custom taxonomy that has months as terms. Inside a view's taxonomy filter, he would like to display them in months order and spread them in two columns
Solution:
Toolset does not offer a way to sort taxonomy terms in a filter. Use a third-party plugin to enforce your custom taxonomy order. Examples:
Problem: I created two CPTs: Events and Profiles. I have a View of Events displayed in the template for Profile posts, and I would like to only display Events where the title of the current Post can be found in the "notes" WYSIWYG field on the Event post.
Solution: Configure the notes custom field Query Filter to use a shortcode attribute and pass the current Profile post title into that shortcode attribute like so: