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 array instead of field value, triggered by Wordpress Importer. #1460

Closed
felipearosemena opened this issue Jun 21, 2017 · 3 comments
Closed

Comments

@felipearosemena
Copy link

Expected behavior

When accessing a TimberPost's property directly, the return value is an array instead of the actual value for that meta field key:

post.some_custom_field // Should print out the raw `meta_value`

Actual behavior

But if for some reason that meta_key has a duplicate in the database, where post_id & meta_key are the same, the following happens:

post.some_custom_field // Returns an array of the raw field values

Steps to reproduce behavior

This issue is made visible quite easily by using the Wordpress Importer. Where even if I export posts using the tool, and import them into the same site, the Wordpress Importer will create duplicate rows in the wp_postmeta table, if the post already existed.

I understand that in some scenarios it would be helpful to save multiple rows of the same post_id + meta_key combination (revisions come to mind). But I don't see why would it ever be useful to spit out array into our template.

The issue goes away if you call post.get_field('some_custom_field'), but sometimes I don't want to get the formatting that get_field provides and I may just want to access the raw value of the field.

I think an ideal scenario would be that, if there are multiple possible values for a given post_id + meta_key combo, then simply assign the latest one of post.some_custom_field when calling TimberPost.

Running WP 4.7.5, PHP 5.6 & Timber 1.3.2

Installed the plugin by downloading from WP.org and replacing it on my file system.

@palmiak
Copy link
Collaborator

palmiak commented Oct 29, 2018

@felipearosemena does this bug still exists? I use WP importer quite often and saw this kind of behavior (thought - I always used php 7 and always used timber from composer).

@felipearosemena
Copy link
Author

@palmiak To be honest I haven't encountered this issue in quite a while. Probably best to direct this question to @jarednova

@Levdbas
Copy link
Member

Levdbas commented Mar 21, 2023

Probably stale by now. Can be closed IMO.

@gchtr gchtr closed this as completed May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants