Support Forum
Hello,
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>
Hi 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/
No 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>
Hi,
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.
This is not woring...
any idea whats happening?
Hi,
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?