wordpress-custom-fields-permalink-plugin
wordpress-custom-fields-permalink-plugin copied to clipboard
Getting Concatenated Field Value in Permalinks
We are having an issue where some of the generated permalinks are having the custom locale field concatenated.
Permalinks Settings Code
/%field_locale%/%postname%/
Custom Locale Field Value

Expected

Reality

We are on version 2.0.
This is very inconsistent and rarely happens. The affected locales seem different each time too.
I hope this is enough information to diagnose the problem, happy to provide more if needed
Hello, thanks for contact. Could you please check in the database, whether your custom field locale for thi particular post does not have multiple en-ca values?
Yes, I found that if I create a duplicate locale value in the wpdb_postmeta table it concatenates them


That' the issue. Plugin concatenates duplicated values by default.
If you want to have the single value, you can:
- See what https://github.com/athlan/acf-permalink offers
- [or] Use hooks to remove duplicates: https://github.com/athlan/wordpress-custom-fields-permalink-plugin/wiki/Plugin-hooks
- [or] Specify the separator joining values using aforementioned hooks or acf extension
I can't see any way to format a text field to only show one value, would you be open to a pull request to fix this?
Hello,
It's already supported in plugin. wpcfp_get_post_metadata filter should do a trick for you. You'll receive all post params and then you can assign the single one to array key which will be used.
But anyway, it's little strange that you're facing such issue, because plugin should take the very first value of meta field, we have even test for that.
- Could you also pase here output of
var_dump(get_post_meta($post->ID)));
of your case? 2. Could you share permalink structure?
Which resulted in

I can't get that output currently, but tomorrow I should be able to
Different recipe, same issue, here's the var_dump output

@athlan If the plugin is supposed to take the first value, doesn't this make it a bug?
