How to add custom field in event post for wordpress

 Dont use wordpress custom field using support use already available plugins

1- Advance custom field plugin

2- Custom Metaboxes 2 plugin.

So go to plugin and install advanced custom fields plugin

In advance custom field plugin go to fields groups

Give Name Event Date and click Add field. in field type select Date Picker

Field Label  Event Date and field name -event_date make required.

Make Date deafult selection and for return format make ymd option

In location rules select post type event.

and save changes.


Lets edit any event for see custom filed option. and add new date and update event date.

Now i want display custom field in front-page.php and find event .

And in Date for month and day add below code ->

    <span class="event-summary__month"><?php  
          $eventDate = new DateTime(get_field('event_date'));
          echo $eventDate->format('M');
          ?></span>
          <span class="event-summary__day"><?php echo $eventDate->format('d');  ?>
        </span>

and save.



Comments

Popular posts from this blog

Basics Of PHP

Creating App.js for Node Application

WordPress Full Guide For Developer