Dear users,

Today we’ll guide you how to add additional DirectoryEngine Directory WordPress Theme custom fields  for the “Edit a place” form.

Simply follow three below steps to get the work done:

  1. Add input field so that the users can add field’s value.
  2. Save the field to database.
  3. Show the field.

For example, we will try to add a new field “panopress” in the “Edit a place” form. This field will be displayed in the header tab, once you’ve complete all the change:

custom fields DirectoryEngine Business Directory Software

For your further information, PanoPress is a WordPress plugin for displaying 360 degree panoramas on your site. You can check out this following link for more detailed information about this plugin: http://www.panopress.org/

Please don’t forget to integrate PanoPress plugin first before adding the new field. Once the field is successfully implemented, users can insert a PanoPress link in the field and it will display a panoramic image on the header of the place’s single page.

Let’s take a look at the guide:

  • The meta name will be panopress.
  • Firstly, you can modify the file “template-js/modal-edit-place.php” to add an input field. The field name & id should be panopress.
<div class="form-field edit-cover-image">
<label><?php _e("PANOPRESS", ET_DOMAIN) ?></label>
<input type="text" class="" name="panopress" id="panopress" placeholder="e.g. [pano file='http://asturias360.com/panara/']"/>
</div>
<div class="form-field edit-cover-image">
<label><?php _e("VIDEO", ET_DOMAIN) ?></label>
<input type="text" class="" name="et_video" id="et_video" placeholder="e.g. https://www.youtube.com/watch?v=d7MY1l3kcvo"/>
</div>
  • Secondly, to update the field to database, you can use the hook “ae_update_place”. It’ll help to save the place details after users submit the form.
// update panopress shortcode to datatabse
add_action('ae_update_place', 'update_panopress');
function update_panopress($result){
// check the request
if( isset($_REQUEST['panopress']) ) {
update_post_meta($result, 'panopress', $_REQUEST['panopress']);
}
}
  • Use filter “ae_convert_place” to add the field’ details to the place’s data.
add_filter('ae_convert_place', 'add_panopress');
function add_panopress($result){
// add panopress to convert data
$result->panopress  = get_post_meta($result->ID, 'panopress', true);
return $result;
}
  • Finally, to show the field in single-place header, you should edit the file “single-place.php” as following.
if(isset($place->panopress) && $place->panopress) {
?>

Note:
You can add the field details to place info by editing template/single-place-details.php 

If you want to add Input field to “Submit place” form, you can edit the file “template/post-place-step3.php” and use hook ae_insert_place

add_action(‘ae_insert_place’, ‘update_panopress’);

You can also use hook “the_content” to show field’s info below the “ Place’s description”.

add_filter('the_content', 'show_field_below_description');
function show_field_below_description($content){
global $post;
$panopress = get_post_meta($post->ID, 'panopress', true);
return $content.'
‘.$panopress.’
';
}

That’s all!

2 Comments
  • morganthx
    Dec  03RD,  2014

    Wonderful post. Thank you for the guidance.

    • nhunq
      Dec  04TH,  2014

      I am very happy to hear that!

      Thanks for your supports! 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

FrE Credit Plus out now. Get FreelanceEngine & plugins with up to 25% discount!!
Grab the deals