Support Forum
Hey folks,
I did a search, but was not able to find a solution. This is probably an easy change, but I am new at this so I am stuck.
Anyways, I am create an event page from a custom post type. One of the custom fields is the "Date", however the output is not for format that I am looking for.
I am trying to get eg: April, 30, 2021 ... this is what I have, but no go.
Any thoughts would be appreciated. =)
Cheers
https://drive.google.com/file/d/1S3h8RClqHprClnNgyDk3U5CVCBpcqLCg/view?usp=sharing
https://drive.google.com/file/d/1KVQLFQCSlEmz3H1mwh6U_0lj7LD3WDBq/view?usp=sharing
Hi Zenjukai,
Thank you for reaching out.
I've tested the dateFormat
setting again and see it displays on the frontend as the format on the backend. Can you please share the code that creates the custom field and show it on the frontend?
You can use the option Get PHP Code
in the Builder to generate the code https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code
Hello Long,
Thank you for your reply. Here is the generated PHP code. I am using Oxygen and Script Organizer, so I took the generated code and then created a script to run, as I don't have a functions.php file. The format still doesn't change. Any thought?
<?php
add_filter( 'rwmb_meta_boxes', 'rswp_oxygen_dateFormat_events' );
function rswp_oxygen_dateFormat_events( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Event Details', 'rswp_oxygen' ),
'id' => 'event-details',
'post_types' => ['event'],
'context' => 'after_title',
'fields' => [
[
'name' => __( 'Event Details', 'rswp_oxygen' ),
'id' => $prefix . 'event_details',
'type' => 'textarea',
'rows' => 6,
'required' => 1,
'save_field' => 1,
],
[
'name' => __( 'Event Date', 'rswp_oxygen' ),
'id' => $prefix . 'event_date',
'type' => 'date',
'required' => 1,
'js_options' => [
'dateFormat' => 'd-MM-yy',
],
'save_field' => 1,
],
[
'name' => __( 'Event Time', 'rswp_oxygen' ),
'id' => $prefix . 'event_time',
'type' => 'time',
'required' => 1,
'save_field' => 1,
],
[
'name' => __( 'Event Location', 'rswp_oxygen' ),
'id' => $prefix . 'event_location',
'type' => 'textarea',
'required' => 1,
'save_field' => 1,
],
],
];
return $meta_boxes;
}
Sorry, I am new at this, so still a bit of a learning curve. Thanks again for your help.
Cheers
Also Long, just as an FYI. I have tried the same output on a theme based site that used "Views" instead on injecting the code and all works great.
So I am wondering if it has to do with the setup or the execution with Oxygen?
Cheers
Hey Long,
Me again ... so never mind with the issue above. What I am seeing is the error is not coming from me or the plugin, but rather how Oxygen renders the custom variables. Yes it can probably work somehow, but it seems kind of pointless to make a hack for a simple process.
I love metabox ... it is an amazing plugin that makes life so much easier, so to just hack it for a simple function doesn't make sense.
So I am just going to move away from Oxygen and just use Views with Twig! =)
Cheers and thanks again for your time and effort.
Let me know if you have any questions.