Field name php refferer
- This topic has 5 replies, 2 voices, and was last updated 3 years ago by
Long Nguyen.
-
AuthorPosts
-
April 11, 2022 at 11:59 PM #35567
victoria de clasca
ParticipantHello,
Wich is the code for the field general metabox on php, for calling a field of metabox ina Oxygen COde Block.
so I want to replace
$toolset_field
for
$metabox_field
is not working
thank you
Here is the code block:
<?php
// Get the post ID
$post_id = get_the_ID();
$toolset_field = "fecha_de_evento";
// Get the Toolset date
$timestamp = get_post_meta( $post_id, $toolset_field, true );
// Convert string to int
$timestamp_to_int = (int)$timestamp;
// Convert string to date
$date = (date_i18n('l, j F.', $timestamp_to_int));
?><div class="my-date"><?php echo $date;?></div>
April 12, 2022 at 5:06 PM #35587Long Nguyen
ModeratorHi Victoria,
No matter what tool is used to create and save the field value to the database, you can use the function
get_post_meta()
to get the post meta.If you are using Toolset to create the custom fields, you can follow this article to use Meta Box to manage the field https://metabox.io/move-custom-post-type-custom-field-data-from-pods-to-meta-box/
April 15, 2022 at 7:04 PM #35656victoria de clasca
ParticipantNo I am not using tioolset I amb using Metabox,
but I am using a code block from another webpage so I can use the code for a new site.This is not working.....:
<?php
// Get the post ID
$post_id = get_the_ID();
$metabox_field = get_post_meta("fecha_de_evento");
// Get the Toolset date
$timestamp = get_post_meta( $post_id, $metabox_field, true );
// Convert string to int
$timestamp_to_int = (int)$timestamp;
// Convert string to date
$date = (date_i18n('l, j F.', $timestamp_to_int));
?><div class="my-date"><?php echo $date;?></div>
April 16, 2022 at 9:22 AM #35666Long Nguyen
ModeratorHi,
Did the custom field ID on the new site as same as the old site? I think this code does not work
$metabox_field = get_post_meta("fecha_de_evento");
There is no post ID passed to the function
get_post_meta()
, please change it to$metabox_field = "fecha_de_evento";
If you insert the code into the Oxygen builder, you can try to contact Oxygen support to ask for implementation of the code. Or add the code to the post template file (deactivate Oxygen) to check it works first.
May 11, 2022 at 11:09 PM #35992victoria de clasca
ParticipantThis is not woring...
any idea whats happening?May 13, 2022 at 7:36 AM #36005Long Nguyen
ModeratorHi,
Can you please share the code that creates the custom fields on your end? And share some screenshots when you add the code to output the field value.
Did you try to add the code to the post template file (deactivate Oxygen) to check if it works? -
AuthorPosts
- You must be logged in to reply to this topic.