Skip Navigation

[Resolved] view display posts after filtering

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)

This topic contains 8 replies, has 1 voice.

Last updated by Dido 1 week ago.

Assisted by: Minesh.

Author
Posts
#2861977

Op hidden link
There is a view containing therapist data, so users can search for one in their area. I would like to show all of them on the map at once, but not all of them listed below the map, because that made the website very slow.

How can I achieve this? I already tried a few things with ClaudeAI, but now they are no longer loading at all, not even after applying a filter.

[wpv-conditional if="( '[wpv-attribute name='url_param' item='toolset_maps_distance_center']' ne '' ) OR ( '[wpv-attribute name='url_param' item='wpv-wpcf-voornaam']' ne '' )"]
<div class="kader">
<h3>hidden link</h3>
[wpv-conditional if="( $(wpcf-site) gt '0' )"]hidden link[/wpv-conditional]<br />
[types field="straatnaam"][/types]<br />
[types field="postcode"][/types] [types field="stad"][/types]
</div>
[/wpv-conditional]

#2861981

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

When I checked the page you shared: hidden link

I can see that few markers on map.

As I understand - on first page load, you want to dispaly all the markers on the map and then when user filter it it should display the markers according to search query. Is that correct? If yes:

Can you please share admin access details and tell me what view you created. You can revert the changes you made using AI and then send me access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2862271

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I can see the page here: hidden link

It seems you are displaying all the posts. And your requirement is you want to display all the markers on the map but least posts. How many posts you want to disply? 10-15 on first page load?

#2862284

Hi Minesh,

All posts are currently displayed on the map. That already works perfectly, and I would like to keep it that way.

However, at the moment all posts are also displayed below the map. Because there are so many posts, the page loads slowly.

Ideally, I would like the posts below the map to be hidden initially and only appear after filtering. For example, if I search for “Middelburg (Netherlands)”, the map should show 12 posts and the same 12 post cards should appear below the map. (div kader)

#2862286

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Do you want pagination?

You will require a "Search" button and the view's Custom Search setting "Full page refresh when visitors click on the search button" - is that Ok for you?

#2862539

Yes, that's ok, if needed.

#2862541

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - but by default you want to display all posts on map - correct but no post under the map. Under the map posts should be displayed when user search - is that correct? And 12 posts per page - correct?

#2862542

Ok - but by default you want to display all posts on map - correct but no post under the map.
YES!
Under the map posts should be displayed when user search - is that correct? And 12 posts per page - correct?
No, 12 was just an example, that's the number of posts if you search location "Middelburg, Zeeland, Nederland"

I want all posts show up in one time, related to the search filter.
2nd example: search location "Vlissingen, Zeeland, Nederland" and you find 10
Amsterdam, Noord-Holland, Nederland you find 38

#2862545

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now:

I've added the following view "show-markers-on-map" that will be sued to display the map marker:
- hidden link

with the above view "show-markers-on-map" I've added the same query filters as you have with your original view "kaart":
=> hidden link

Custom field filter
Select items with field:
Openbaar is a string equal to Openbaar
AND
Voornaam is a string equal to URL_PARAM(wpv-wpcf-voornaam)

And added the following code to the "show-markers-on-map" loop editor section which I moved from your original view "kaart":

<wpv-loop>
           [wpv-map-marker map_id='overzicht' marker_id='marker-[wpv-post-id]'  address="[types field='adres'][/types] [types field='stad'][/types]"]
          <strong>Bekijk gegevens: [types field='bedrijfsnaam-praktijk'][/types]</strong><br/>
          <p><em><u>hidden link</u></em><br />
          [types field='stad'][/types]</p>
          [/wpv-map-marker]
		</wpv-loop>

And with your "kaart" - I've added the "show-markers-on-map" view just after the [wpv-map-render] shortcode:
=> hidden link

[wpv-map-render map_id="overzicht" map_height="600px"][/wpv-map-render]</div></div>
[wpv-view name="show-markers-on-map"]

And also:
- added the "Search" button to "Search and Pagination" section
- Enable the pagination and display 12 results per page
- changed the Custom Search Setting to "Full page refresh when visitors click on the search button"
- deleted the [wpv-map-marker] shortcode from the loop editor and added to "show-markers-on-map" view's loop editor section.

I've also added the following code to "Custom Code" section offered by Toolset with the code snippet "toolset-custom-code":

add_filter('wpv_filter_query', 'func_hide_search_result_until_search_perform', 10, 3);
function func_hide_search_result_until_search_perform( $query_args, $view_settings, $view_id ) {
      
    if($view_id == 3287 ){  
         if( !isset($_REQUEST['wpv_view_count']))  {
            $query_args['post__in'] = array(0);
        }
                      
     }
    return $query_args;
}

Can you please confirm it works as expected.

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/
- https://toolset.com/documentation/legacy-features/views-plugin/views-pagination/
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

#2862547

it's working fine.
I loved the url stays the same in the formal version. That's not possible in this format, but not the worst part. 😉