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

Post meta values replaced when there are multiple same block. #14545

Closed
ravishakya opened this issue Mar 21, 2019 · 5 comments
Closed

Post meta values replaced when there are multiple same block. #14545

ravishakya opened this issue Mar 21, 2019 · 5 comments
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@ravishakya
Copy link

When you add multiple same blocks and the values of the block are saved in post meta, it seems it is replacing the values. I can save the value in attribute but I don't want that. What is the best way to handle this ??

@youknowriad youknowriad added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Mar 21, 2019
@youknowriad
Copy link
Contributor

Not sure I undersand the question

it seems it is replacing the values

Who is replacing which value? Can't you expand more?

@ravishakya
Copy link
Author

My question is same as this thread #5599

attributes: {
    catID: {
        type: 'number',
	default: 0,
        source: 'meta',
        meta: 'catID',
    },
},

When you have same two blocks the value of "catID" is replacing because one post meta has been used for both fields.

@youknowriad
Copy link
Contributor

Well, that's "normal" because you're using the same post_meta for both, if you change one, it changes everywhere. If you want separate values per block you shouldn't use a post_meta for this or you should use a different meta key.

@ravishakya
Copy link
Author

Thats a big limitation. It would have been easy if we have "block_meta" table like "wp_postmeta". All the block attributes are save on "block_meta" instead on the_content().

and we can do something like this to get the block data.

get_block_meta( $post_id, $block_id , 'block_key' );

A separate table for blocks. Just my view.

@youknowriad
Copy link
Contributor

The backend at the moment has no knowledge about blocks, so there's no block_id etc... Adding such feature is not our current roadmap. It's a big feature and it's not clear what user user-case this would solve.

Thanks for the suggestion, let's reconsider if there's more similar feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

2 participants