Skip Navigation

[Resolved] Map Missing Results

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 11 replies, has 2 voices.

Last updated by Beda 5 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1345227

I am trying to: display all results in a map

Link to a page where the issue can be seen: hidden link

I expected to see: all posts with the ACF Field labeled 'year' filled as '2019'

Instead, I got: only 2 of the expected results.

Video of the issue: hidden link

#1345261

I see that when I select 2019 in the Year dropdown and the Query updates the results, only 2 items are rendered on the map.

Either the Posts do not all have the Field "Country" filled out, or not all posts have a Taxonomy as you set in the Query filter, or not all posts have a Year field.
You show the Year fields is present so it must be either of the other.

If not, then it's in the complex HTML conditions you use in the Loop.

I would proceed as follows:
1. Duplicate the View
2. Remove all Query filters and add the country filter again
3. If that works proceed back-adding all other filters, if it does not work, remove all Loop content and regenerate it
4. if that works (without any HTML condition) the issue is within those, and you can find out which, by adding one by one back in to the view

Finally, it might be due to a missing address field, but given when there is no query, all posts appear, I do not thin that is the issue.
Does the View output everything if you do NOT use a Map but a simple list?
That can also be tested in a duplicated View.

Note, ACF Fields sometimes are complex fields, but this one seem a simple text field so I see no reason it wouldn't work with Toolset

If all of above fails, can you send me a duplicate?
https://toolset.com/faq/provide-supporters-copy-site/

#1345623

Thanks for your help Beda!

There are many results displayed when using a simple list result instead of a map, which can be seen towards the end of the video I sent previously.

I'd be happy to provide a copy of the site for further testing!
Is this where I should provide the login info you would like created?

#1346895

Yes, I had activated an area previously, so you can add the copy or/and access (to test sites or live).
I reactivated it now.

If possible, add a copy of your site with the steps to follow so to replicate the issue on it.
Then I can duplicate that locally and see what's wrong.

If yo have a staging site I can also take a look there first, I prefer not to touch live sites if not for looking.

Please add which ever you prefer 🙂

#1349923

There are some things the Dashboard tells me before we can continue:

1. Toolset Maps: You've got some address data cached. Convert it to a new, more efficient format to gain significant performance benefits on Troubleshooting Page!

Please can you perform the suggested step so we can work with the latest standards of the plugin?

2. hidden link

Please perform all updates asked for, that is important to exclude any conflict of fixed problems

3. If at this point the issue persists, please perform the basic steps (deactivation of other software) to test if that solves the issue

If at this point this issue is still appearing, please could you explain to me how everything was created and how it's intended to work, because right now, it's not clear how the data is created, stored and retrieved or how it is displayed, and what you want to achieve with this display (I am clear about the search functionality but not about what or how you want to display).

See, the address usually comes from a Toolset Address fields, but it seems you use "Lat" and "Long" fields and pass latitudes and longitudes to the fields.
This is OK, even if it is not really how it's supposed to be used (but it is sometimes required), however the ShortCodes in the View loop showing those lat/long are broken, as you can see they are highlighted in red, indicating errors. They are overheated and conflict with their apostrophes, which is a WordPress core problem.

I can due to that not duplicate the view and re-use it on your site - it simply does not work at all.
So there must be several additional step that you have taken to make it work at the first place. I need to know how this was built so to determine if it is supported and how we can solve it.

I think, after above steps the issue probably will be resolved, but please let me know if not, we can then proceed with further analysis.
I would then immediately as first thing, remove all HTML conditions from the loop of that View to test.

#1350403

I believe I have cleared the cached address data, and I have updated the outdated plugins.
The issue is persisting.

I have a CPT named In Action with ACF Fields for Lat, Lng, Country, and Year. It works as it should using a custom PHP solution on this site: hidden link
As you can see at that address, there are many results for the year 2019.

When I exported the posts of that CPT and imported them to the new site, along with all data and custom fields, everything looks good. And Toolset support helped me find the shortcode to use to get them to display on the map. But, for some reason there are still the correct results below the map if I have them display just their HTML values, but some of them don't appear on the map. Please compare the HTML results or the results on the link above to the results on: hidden link for the year 2019.

Feel free to change anything in the view for the sake of troubleshooting to find or fix the issue, I have already made a backup of the view.

Thank you.

#1350781

I understand.
The issue is, the ShortCodes are as it is visible, broken.
They are not using the correct apostrophes/quotes.

Also the setup is very intricate with conditions, which makes it impossible to be sure what is faulty, and what not.
In such cases one needs to take apart the single items.
So for example, create a View in a very minimal and unconditional state, to see if that works, then proceed to more complex setups, and so forwards until the issue is found.

I understand you have the post type "In Action" (hidden link), and use instead of the provided Toolset Address Field (and others) and ACF provided solution.
If those Fields are simple fields, that should not be a big issue, however remember that only Toolset registered fields work with full features in Searches, for example creating selectable lists with other field types may fail, if they are not registered by Toolset.

It should not affect this particular aspect, however.

I took a look at the addresses you have and there seems to be only one cached right now:
34 Poniu Circle, Wailuku, HI, USA 20.8780099 -156.502369

So that means you need to load one by one the page again (it will cache each time 10 addresses, that is the limit of Google).
Then, all the addresses will appear on any map you use, and not before.
So if you have 300 addresses, you will need to load that page 30 times under circumstances until all addresses are cached.
That is how google works, it's not due to Toolset.

Now, as I mentioned you also have uncached addresses, as it states in the dashboard, and it does not seem to be converted, as it still expects to do that hidden link:
You've got some address data cached. Convert it to a new, more efficient format to gain significant performance benefits.
==> Convert cache

This is for the new way of Toolset to store the addresses, but I fear this will only work with Toolset registered address fields, I am honestly not sure about that, and will need to ask the developer on Tuesday.

To proceed for now, I left that as is and created a View, where I query the Post Type "In Action" and display a map with the markers using the lat and long fields of the "non toolset fields".
The problem is it offers me a "lat " field (with spaces), one "lat", then additionally one "_ lat" and one "_lat".
In ACF however I see only a "lat": hidden link
Same for lng.
So which one it is, that is a problem, that Toolset Views will not be able to solve.

You would need to make sure to have only ONE field of that exact slug and that field must be the one saved for all those posts.
If you created and deleted fields, (at least with Toolset) you should remove them from the database (in Toolset you can do that with a WordPress backend command). With ACF I am not sure.
The case is that there are each more than one such field and Views will not know which to get.

I decided arbitrarily to use [wpv-post-field name='lat'] and [wpv-post-field name='lng']
Initially I thought they seem to work:
hidden link

But do you see the Lat and Long output there?
It is for each post:
47.556446, 47.556446/7.586509, 7.586509

But I only added [wpv-post-field name='lat']/[wpv-post-field name='lng'] to my loop, so I expect only 47.556446/7.586509
The ACF field does something unexpected here, and that can not work with a map - it is not a valid Lat and long value.

When I output the underscores variant (_lat and _lng), I get values like
field_5a0efe883e001, field_5a0efe883e001/field_5a0efe933e002, field_5a0efe933e002

So here we get the Field ID of ACF.
Then, when I output the ones with spaces, I get nothing.

So it seems that the only fields returning a valid return for each the value twice, comma separated:
47.556446, 47.556446 and then 7.586509, 7.586509

And logically that is because there are 2 "lat" and 2 "lng" fields registered, probably in the database only, since they are not visible in ACF's admin, but Views gets them in the Loop Editor GUI.

What am I missing here?
The field indeed seems to simply output a doubled value, which will not work for the purpose you want to use it.

But why would it do that?
Do you have any other method to display those ACF fields? Maybe we can use a Custom Shortcode instead, to see if that works for now?
One could use a get_post_meta() inside a ShortCode, for example.

// [acf-fields field="field-slug"]
function ts_get_fields( $atts ) {
        $post_id = do_shortcode("[wpv-post-id]");
	$a = shortcode_atts( array(
		'field' => '',
	), $atts );
        $field_value = get_post_meta($post_id,$a['field'], true );
	return $field_value ;
}
add_shortcode( 'acf-fields', 'ts_get_fields' );

Something like above could work.
However, first I'd like to hear your opinion on the doubled output, I feel I miss something important.

#1350949

Thank you for your time and your detailed response!

Perhaps the doubled output is because the ACF Field Groups provided PHP code that I added to the active Child Theme's Function.php file? Without that, the data when entered into a new In Action post wouldn't save.

I would ideally switch to using Types fields instead of ACF but with so many entries and no import tool from ACF to Types I don't think we can allocate the hours to re-enter all that data.

I've just tested it without the fields registered in functions.php as well and that didn't seem to fix the doubled output on the test page.

If you have any ideas, please feel free to try what you'd like on the site.
I'm really stuck here.

Thank you!

#1351919

I have an idea! Perhaps it's because some of the posts in this CPT have been Imported multiple times from the old website?

Is there a way to scan the database for repeated entries and remove them?

Thanks!

#1352345

Yes, that is possible

You will need to clean out those ghost entries, they will break any sort of listing or work with the data.

You can use search tools in PHPMyAdmin that your server provider provides you and search for the meta in post meta table, for example, and delete all the ones with the wrong prefixes or slugs or so to say, duplicates.

I guess you will remove everything with _field and _ field and field (space).
But please first consult ACF what exact postmeta entry is the one that they expect for their fields. Only then delete the rest or rename meaningfully.

After, the views actually should immediately work if the right field is then used/called within.

#1352913

Thanks!

Here is the code they recommended using:

delete from wp_postmeta
where meta_id in (
       select *
       from (
               select meta_id
               from wp_postmeta a
               where a.meta_key = 'change_this'
               and meta_id not in (
                       select min(meta_id)
                       from wp_postmeta b
                       where b.post_id = a.post_id
                       and b.meta_key = 'change_this'
               )
       ) as x
);

Do you know where I should place the field names in that code?

Thanks again!

#1353725

That looks like SQL code so it should be used as a SQL command, for example you can use the PHP MyAdmin to fire such commands.

Note that the snippet is not ready to use, the least I see that you'll have to edit "change_this" as the slug of the field you try to find but pleas ask ACF's support how to get rid of the Duplicate Field entries, we cannot respond for this here (and we cannot provide Custom SQL Code).

Did you confirm that it is not expected to have all these fields with same name, with the ACF Support?
Maybe it's expected? Or there is a smoother way to remove them, or they can show you where to insert the SQL they suggest to use for this deletion?

As mentioned, in Toolset you do that in a WordPress Guided user Interface, with a click of a button, but you cannot do that for non-Toolset Fields I fear, you can try though, in Toolset > Custom Fields > Field Control.
If you can find the other (ACF) fields there it may be possible you can delete them there as well. I honestly never tried if it can also handle 3rd party fields!
(This because it's designed for Toolset Fields by core-idea)

The right thing to do is to ask ACF:
1. Is it expected to have so many fields with the same, and similar slugs?
2. If not, then how can I remove them, and how can I avoid it happening again, in future?

Then we can proceed with the display for the correct field (which, remember, will only work for non-complex fields) and even there may cause some issues.