Tuesday 12 March 2013

Wordpress Midway Theme - Capturing details in admin and retrieving on Tour Pages

I'm using the Wordpress Midway Responsive Theme and I need to change the booking and inquiries buttons so that they can go to various locations and email boxes.

So firstly I need to add a couple of boxes in admin; so we can save the information relevant to each tour.

OPEN

wp-content/themes/midway/framework/config.php

FIND

//Tours
            array(
                'id' => 'tour_metabox',
                'title' =>  __('Tour Options', 'midway'),
                'page' => 'tour',
                'context' => 'normal',
                'priority' => 'high',               
                'options' => array(

UNDERNEATH ADD

array(    'name' => __('BookLink','midway'),
                            'desc' => __('The Link where we want Booking to go to.','midway'),
                            'id' => 'bookinglink',
                            'type' => 'text'),   
                    array(    'name' => __('EmailLink','midway'),
                            'desc' => __('The Email address that enquiries should go to.','midway'),
                            'id' => 'emailaddress',
                            'type' => 'text'),   



SAVE and UPLOAD


after this change you'll then have extra input boxes in Admin.  And miraculously your infromation here get saved with no more changes need.  Out of interest those details are saved in the table  'wp_postmeta'  which uses these fields.
'meta_id, post_id, meta_key, meta_value'



To retrieve this infromation you'll need to make a function like

function themex_emaillink($id=null, $before='', $after='') {
   
    $emaillink=get_post_meta($id,'_tour_emailaddress',true);
   
    $out=$emaillink;
   
    return $out;
}


which you should save in a file like function.php

AND THEN TO PICK THE INFORMATION UP IN YOUR TEMPLATE

at the top of the page use

$emaillink=themex_emaillink($post->ID);


and then use  $emaillink in your page where you want to out put that information.






No comments: