Views plugin provides an API, making it easy to display Views output using PHP.
When you ask for help or report issues, make sure to tell us all related information about your View and the data that you want to display using the Views API.
Viewing 15 topics - 451 through 465 (of 480 total)
Problem:
How can I get the current index of the item displayed in a View?
For example, I want to set conditions for different items in the loop, depending on whether they are at the begin, end or elsewhere in the loop.
How can I achieve that?
Solution:
We have a ShortCode that lets you address the loop index, which you can use to address practically every single iteration in the Views Loop.
If you need more fine-grained control over the iteration counting, eventually a Custom ShortCode can help, for which we have an example linked below.
We don't, however, provide custom code; the example is for reference only.
I want to know if I can filter my site according to users location ?
by making user submit a form contain his country , city and use these fields in content templates and filtering views automatically no manually ?
as I need to make a real estate website contain many cities and each city contain many posts
if user enter the site , I need him to select his location and the whole site show the content related to his location
and save these entries as cookies for his browser
Link to a page where the issue can be seen:
Is this possible using Toolset with Toolset Cred , Toolset Maps & Toolset views
Solution:
I assume you are going to achieve this:
Provide a test input box for user inputting address text, submit the form, then locate the address in the google map, and filter the results by distance range.
If it is, this is built-in feature of the latest version of Toolset Map plugin, see the document:
They enter the location and a distance radius within which to display markers. If your site is using HTTPS protocol, visitors can also use their own location as the center of the search.
The problem here is that the customer essentially created a custom function to evaluate in our wpv-conditionals shortcode but this function was not working in the shortcode.
Solution:
In order for this to work you will need to add the function name in our views 3 party functions argument.
You can add the function name to the view 3rd party functions by going to Toolset -> Settings -> Frontend
Problem:
How to allow comma to view's number field filter
Solution:
You can use view's filter hook wpv_filter_query to modify the view's query on fly and adjust it as per your requirement by hooking custom query filters to it.
The problem here is that the user is using the wpv-after-display-post hook in order to do a views counter on his post. This means that the counter should increment each time the post is loaded on the page using views.
The code that the user is using can be seen below.
// Add our callback
// Mind that we set a priority of 2 and we expect 2 arguments
add_action( 'wpv-after-display-post', 'my_count_on_views', 10, 2 );
// Define our callback
function my_count_on_views( $post, $view_id ) {
if ( $view_id == 207615 ) {
// Only do something if the current View is our View, with ID 44
$counter = get_post_meta( $post->ID, 'my_counter', true );
$counter = $counter + 1;
update_post_meta( $post->ID, 'my_counter', $counter );
}
}
The user is storing the counter inside a custom field but the field itself is not being updated with the value.
Solution:
The solution is that since you are using a custom field created using Types then you will need to user the wpcf- prefix when you are referencing the field using the wordpress post meta functions.
In this users case he should've retrieve the field like this wpcf-my_counter.
This plugin creates a CPT in WordPress and not only imports Vimeo videos but also the meta-data for each video directly from Vimeo, including the thumbnail, description, title, etc. as entered in the settings for each video on Vimeo.com,
I am hoping to use this CPT and this meta data in Views. I want to display the thumbnail and title of the video on the front end that links to a page containing the video itself.
I can see the vimeo-video CPT in my Toolset dashboard but I am unable to create a field group in order to create a View.
Solution:
The "vimeo-video-post" plugin stores field value as an array in a single custom field "__cvm_video_data", so it can not be displayed directly within Views shortcode, but you can create a custom shortcode for it,
for example, you can use wordpress function add_shortcode() to register a new custom shortcode
Then output values as what you want, I suggest you check it with the author of Vimeo Video Post plugin, check if there is any existed shortcode within Vimeo Video Post plugin, if there isn't add a feature request for it.
Problem:
Use custom fields in views secondary sorting.
Solution:
Unfortunately we don't have a way of doing this without some form of custom coding to add the additional fields to sort by.
Currently we can only sort by the default ones that you see that are currently available.
However since its not impossible to do but the custom coding falls out of the scope of our support forum. I would recommend contacting one of our certified consultants in order to achieve.