Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Concatenated Field Value in Permalinks #43

Open
puremana opened this issue Mar 21, 2019 · 8 comments
Open

Getting Concatenated Field Value in Permalinks #43

puremana opened this issue Mar 21, 2019 · 8 comments

Comments

@puremana
Copy link

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
image

Expected
image

Reality
image

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

@athlan
Copy link
Owner

athlan commented Mar 21, 2019

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?

@puremana
Copy link
Author

Yes, I found that if I create a duplicate locale value in the wpdb_postmeta table it concatenates them

image

image

@athlan
Copy link
Owner

athlan commented Mar 23, 2019

That' the issue. Plugin concatenates duplicated values by default.

If you want to have the single value, you can:

@athlan athlan closed this as completed Mar 23, 2019
@puremana
Copy link
Author

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?

@athlan
Copy link
Owner

athlan commented Mar 25, 2019

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.

  1. Could you also pase here output of
var_dump(get_post_meta($post->ID)));

of your case?
2. Could you share permalink structure?

@athlan athlan reopened this Mar 25, 2019
@puremana
Copy link
Author

  1. image

Which resulted in
image

I can't get that output currently, but tomorrow I should be able to

@puremana
Copy link
Author

Different recipe, same issue, here's the var_dump output

image

@puremana
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants