Tell us what you are trying to do?
Display view of nearby places relative to the current post (has custom address field) using block editor. I have trouble setting the mapcenter with the block editor (there is no shortcode that older support articles refer to).
Every advice that I saw suggests adding the following:
[wpv-view name="list-of-apartments" mapcenter="[types field='map-apartments' output='raw'][/types]" cached="off"]
But the block editor no longer uses the shortcode.
Minesh, could you explain why this does not work (see screenshot)? If only this shortcode [types field='map-apartments' output='raw'][/types] resolved into a fixed address, it would work...
The option you highlight is used to only display the address string, it will not parse the shortcode.
I've another way but that will require add the view's API hook that could work. So you have two options, either go for classic view or send me problem URL where you added your view with access details so that I should try to add a view's API hook and see if that help you to resolve your issue.
*** 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.
Thank you for sharing access details but when I try to submit the admin access details to login form and when I click on submit button I can see the white page with the error: 502 Bad Gateway
Can you please send me working site so I can login to your system and try to make changes accordingly.
I have set the next reply to private which means only you and I have access to it.
I like the approach - thank you for this idea! For my general education - is there an easy way to view all the views and their IDs? In this case, how do I know that view 625 is in fact view named nearby3?
In any case, I *think* I could make the snippet less fragile by just using this conditional instead of if ( $view_id == 625 ):
if ( $post->post_type == 'place' )
And final question - given the snippet above, which option do I chose in the screenshot? I tried the top 3 but it didn't filter anything out... But maybe it was just a matter of me using the wrong view id 🤷♀️
You can able to see the View IDs here with the view's listing page:
=> hidden link
And final question - given the snippet above, which option do I chose in the screenshot? I tried the top 3 but it didn't filter anything out... But maybe it was just a matter of me using the wrong view id
==>
you should use the option "Distance Center is set using the fixed location" and add some dummy distance address value there as it will be overridden by the hook value.
>>you should use the option "Distance Center is set using the fixed location" and add some dummy distance address value there as it will be overridden by the hook value.
I spoke too soon... I've set a far away place into the fixed location, and no items are being returned... The mapcenter is being ignored...
There are two things:
1 Setting a map centre
2 Filtering the view results with address string coming from your custom field: [types field='place-address'][/types]
Currently, we implemented 2 and I set the shortcode "[types field='place-address'][/types]" to the option "Distance Center is set using the fixed location" as address value. Does it works now? If yes, this is the way it should work, as this is a workaround.
As you mentioned yourself, "Distance Center is set using the fixed location" does not accept a shortcode. I tried putting "[types field='place-address'][/types]" into it, but it has no effect.
I also played a bit more with URL param option, and changing to add_filter() priority from 10 to 100, so that it runs later and overrides the empty URL param, but that didn't have any effect either...
As you mentioned yourself, "Distance Center is set using the fixed location" does not accept a shortcode. I tried putting "[types field='place-address'][/types]" into it, but it has no effect.
==>
yes, but is query filter is active. I asked you to put a shortcode a dummy value, as we are overriding the value of shortcode with actual address field value of your current post using the filter I shared here:
=> https://toolset.com/forums/topic/display-view-of-nearby-places-relative-to-the-current-view-using-block-editor/#post-1893669
As said, we have two things:
1 Setting a map centre
2 Filtering the view results with address string coming from your custom field: [types field='place-address'][/types]
==>
What option you want?
- Do you want to set the map center or filter the view results using the custom address field?
As I understand, your requirement is to filter the view result with the current post address filed "place-address" and display that marker on the map - correct? If yes, on what post its not working, Can you please share URL of that post?
If I misunderstood something here, please feel free to correct me. 🙂
>>What option you want?
Any option that works... I just cannot do [wpv-view name="nearby" mapcenter="[types field='place-address' output='raw'][/types]" cached="off"] because I plan on adding a lot of styling with the block editor.
The goal is to view a Place, and show a grid of Places nearby. I don't need to show any map at all. No visual map - just a grid view.
For testing - here are all the places - hidden link
hidden link - this place should have a lot of nearby places.
hidden link - this place is far away and should not have anything nearby.
I think we are really close, but not sure why it is not working...