wordpress-custom-fields-permalink-plugin icon indicating copy to clipboard operation
wordpress-custom-fields-permalink-plugin copied to clipboard

Getting Concatenated Field Value in Permalinks

Open puremana opened this issue 6 years ago • 8 comments

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

puremana avatar Mar 21 '19 03:03 puremana

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?

athlan avatar Mar 21 '19 08:03 athlan

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

image

image

puremana avatar Mar 21 '19 22:03 puremana

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

athlan avatar Mar 23 '19 08:03 athlan

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?

puremana avatar Mar 25 '19 03:03 puremana

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 avatar Mar 25 '19 07:03 athlan

  1. image

Which resulted in image

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

puremana avatar Mar 25 '19 07:03 puremana

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

image

puremana avatar Mar 25 '19 22:03 puremana

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

puremana avatar Mar 28 '19 22:03 puremana