What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
I am trying to create a custom post type input using the wp_insert_post
function, this custom post type called game
was created using the pods framework and contains a series of custom fields which I try to give values using the meta_input key
as follows
Example using _pods_
prefix
$entry = [
post_title = {$post-post_title} - {$game-number},
post_content = ... {$id},
post_type = game,
post_status = publish,
meta_input = [
_pods_game_number = $game-number,
_pods_game_date = $game-date,
_pods_fields = $fields,
_pods_league = $id,
]
];
$game_id = wp_insert_post($entry, true);
Example with no prefix
$entry = [
post_title = {$post-post_title} - {$game-number},
post_content = ... {$id},
post_type = game,
post_status = publish,
meta_input = [
game_day_number = $game-number,
game_day_date = $game-date,
fields = $fields,
league = $id,
]
];
$game_day_id = wp_insert_post($entry, true);
For some reason the meta fields are not saved except for the fields
field ... Investigating I read somewhere about using the _pods_
prefix in custom fields but although I can verify that the fields and their correct values are created in the postmeta
table these are not listed in the form. If on the other hand I try to reference the custom fields without the prefix _pods_
they are not created, I confirm this by looking for them in the postmeta
table.
What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
I appreciate your time
Topic pods-framework wp-insert-post custom-field custom-post-types Wordpress
Category Web