This code i will add below is for Custom Fields for Custom Post Type and GMap for Custom Post Type.
Currently both are pulled by this function.
I want to seperate both. One for Custom Fields and One for Map.
Here is the Code:
add_action('tmpl_detail_page_custom_fields_collection','detail_fields_colletion');
/*
Name : detail_fields_colletion
Desc : Return the collection for detail/single page
*/
function detail_fields_colletion()
{
global $wpdb,$post,$detail_post_type;
$detail_post_type = $post->post_type;
if(isset($_REQUEST['pid']) && $_REQUEST['pid'])
{
$cus_post_type = get_post_type($_REQUEST['pid']);
$PostTypeObject = get_post_type_object($cus_post_type);
$PostTypeLabelName = $PostTypeObject->labels->name;
$single_pos_id = $_REQUEST['pid'];
}
else
{ $cus_post_type = get_post_type($post->ID);
$PostTypeObject = get_post_type_object($cus_post_type);
$PostTypeLabelName = $PostTypeObject->labels->name;
$single_pos_id = $post->ID;
}
$heading_type = fetch_heading_per_post_type($cus_post_type);
remove_all_actions('posts_where');
$post_query = null;
if(count($heading_type) > 0)
{
foreach($heading_type as $_heading_type)
{
$args =
array( 'post_type' => 'custom_fields',
'posts_per_page' => -1 ,
'post_status' => array('publish'),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'post_type_'.$cus_post_type.'',
'value' => $cus_post_type,
'compare' => '=',
'type'=> 'text'
),
array(
'key' => 'show_on_page',
'value' => array('user_side','both_side'),
'compare' => 'IN'
),
array(
'key' => 'is_active',
'value' => '1',
'compare' => '='
),
array(
'key' => 'heading_type',
'value' => $_heading_type,
'compare' => '='
),
array(
'key' => 'show_on_detail',
'value' => '1',
'compare' => '='
)
),
'meta_key' => 'sort_order',
'orderby' => 'meta_value_num',
'meta_value_num'=>'sort_order',
'order' => 'ASC'
);
$post_query = new WP_Query($args);
$post_meta_info = $post_query;
$suc_post = get_post($single_pos_id);
if($post_meta_info->have_posts())
{
echo "<div class='grid02 rc_rightcol clearfix'>";
echo "<ul class='list'>";
$i=0;
while ($post_meta_info->have_posts()) : $post_meta_info->the_post();
$field_type = get_post_meta($post->ID,"ctype",true);
if($i==0)
{
if($post->post_name!='post_excerpt' && $post->post_name!='post_content' && $post->post_name!='post_title' && $post->post_name!='post_images' && $post->post_name!='post_category')
{
if($_heading_type == "[#taxonomy_name#]"){
echo "<li><h2>";_e(ucfirst($PostTypeLabelName),DOMAIN);echo ' '; _e("Information",DOMAIN);echo "</h2></li>";
}else{
echo "<li><h2>".$_heading_type."</h2></li>";
}
}
$i++;
}
if(get_post_meta($single_pos_id,$post->post_name,true))
{
if(get_post_meta($post->ID,"ctype",true) == 'multicheckbox')
{
$_value = "";
foreach(get_post_meta($single_pos_id,$post->post_name,true) as $value)
{
$_value .= $value.",";
}
echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> ".substr($_value,0,-1)."</p></li>";
}else if($field_type =='radio' || $field_type =='select'){
$options = explode(',',get_post_meta($post->ID,"option_values",true));
$options_title = explode(',',get_post_meta($post->ID,"option_title",true));
for($i=0; $i<= count($options); $i++){
$val = $options[$i];
if(trim($val) == trim(get_post_meta($single_pos_id,$post->post_name,true))){
$val_label = $options_title[$i];
}
}
if($val_label ==''){ $val_label = get_post_meta($single_pos_id,$post->post_name,true); } // if title not set then display the value
echo "<li><p>".$post->post_title." : </p> <p> ".$val_label."</p></li>";
}
else
{
if(get_post_meta($post->ID,'ctype',true) == 'upload')
{
echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> Click here to download File <a href=".get_post_meta($single_pos_id,$post->post_name,true).">Download</a></p></li>";
}
else
{
echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> ".get_post_meta($single_pos_id,$post->post_name,true)."</p></li>";
}
}
}
if($post->post_name == 'post_excerpt' && $suc_post->post_excerpt!='')
{
$suc_post_excerpt = $suc_post->post_excerpt;
?>
<li>
<div class="row">
<div class="twelve columns">
<div class="title_space">
<div class="title-container">
<h1><?php _e('Post Excerpt',DOMAIN);?></h1>
<div class="clearfix"></div>
</div>
<?php echo $suc_post_excerpt;?>
</div>
</div>
</div>
</li>
<?php
}
if(get_post_meta($post->ID,"ctype",true) == 'geo_map')
{
$add_str = get_post_meta($single_pos_id,'address',true);
$geo_latitude = get_post_meta($single_pos_id,'geo_latitude',true);
$geo_longitude = get_post_meta($single_pos_id,'geo_longitude',true);
$map_view = get_post_meta($single_pos_id,'map_view',true);
}
endwhile;wp_reset_query();
echo "</ul>";
echo "</div>";
}
}
}
else
{
$args =
array( 'post_type' => 'custom_fields',
'posts_per_page' => -1 ,
'post_status' => array('publish'),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'post_type_'.$cus_post_type.'',
'value' => $cus_post_type,
'compare' => '=',
'type'=> 'text'
),
array(
'key' => 'is_active',
'value' => '1',
'compare' => '='
),
array(
'key' => 'show_on_detail',
'value' => '1',
'compare' => '='
)
),
'meta_key' => 'sort_order',
'orderby' => 'meta_value',
'order' => 'ASC'
);
$post_query = new WP_Query($args);
$post_meta_info = $post_query;
$suc_post = get_post($single_pos_id);
if($post_meta_info->have_posts())
{
$i=0;
/*Display the post_detail gheading only one time also with if any custom field create. */
while ($post_meta_info->have_posts()) : $post_meta_info->the_post();
if($i==0)
if($post->post_name != 'post_excerpt' && $post->post_name != 'post_content' && $post->post_name != 'post_title' && $post->post_name != 'post_images' && $post->post_name != 'post_category')
{
echo '<div class="title-container clearfix">';
//echo '<h1>'.POST_DETAIL.'</h1>';
$CustomFieldHeading = apply_filters('CustomFieldsHeadingTitle',POST_DETAIL);
if(function_exists('icl_register_string')){
icl_register_string(DOMAIN,$CustomFieldHeading,$CustomFieldHeading);
}
if(function_exists('icl_t')){
$CustomFieldHeading1 = icl_t(DOMAIN,$CustomFieldHeading,$CustomFieldHeading);
}else{
$CustomFieldHeading1 = __($CustomFieldHeading,DOMAIN);
}
echo '<h3>'.$CustomFieldHeading1.'</h3>';
echo '</div>';
$i++;
}
endwhile;wp_reset_query(); //Finish this while loop for display POST_DETAIL
?>
<?php echo "<div class='grid02 rc_rightcol clearfix'>";
echo "<ul class='list'>";
if($_heading_type!="")
echo "<h3>".$_heading_type."</h3>";
while ($post_meta_info->have_posts()) : $post_meta_info->the_post();
if(get_post_meta($single_pos_id,$post->post_name,true))
{
if(get_post_meta($post->ID,"ctype",true) == 'multicheckbox')
{
foreach(get_post_meta($single_pos_id,$post->post_name,true) as $value)
{
$_value .= $value.",";
}
echo "<li><p class='tevolution_field_title'>".$post->post_title.": </p> <p class='tevolution_field_value'> ".substr($_value,0,-1)."</p></li>";
}
else
{
echo "<li><p class='tevolution_field_title'>".$post->post_title.": </p> <p class='tevolution_field_value'> ".get_post_meta($single_pos_id,$post->post_name,true)."</p></li>";
}
}
if($post->post_name == 'post_excerpt' && $suc_post->post_excerpt!="")
{
$suc_post_excerpt = $suc_post->post_excerpt;
?>
<li>
<div class="row">
<div class="twelve columns">
<div class="title_space">
<div class="title-container">
<h1><?php _e('Post Excerpt');?></h1>
<div class="clearfix"></div>
</div>
<?php echo $suc_post_excerpt;?>
</div>
</div>
</div>
</li>
<?php
}
if(get_post_meta($post->ID,"ctype",true) == 'geo_map')
{
$add_str = get_post_meta($single_pos_id,'address',true);
$geo_latitude = get_post_meta($single_pos_id,'geo_latitude',true);
$geo_longitude = get_post_meta($single_pos_id,'geo_longitude',true);
}
endwhile;wp_reset_query();
echo "</ul>";
echo "</div>";
}
}
if(isset($suc_post_con)):
do_action('templ_before_post_content');/*Add action for before the post content. */?>
<div class="row">
<div class="twelve columns">
<div class="title_space">
<div class="title-container">
<h1><?php _e('Post Description', DOMAIN);?></h1>
</div>
<?php echo $suc_post_con;?>
</div>
</div>
</div>
<?php do_action('templ_after_post_content'); /*Add Action for after the post content. */
endif;
$tmpdata = get_option('templatic_settings');
$show_map='';
if(isset($tmpdata['map_detail_page']) && $tmpdata['map_detail_page']=='yes')
$show_map=$tmpdata['map_detail_page'];
if(isset($add_str) && $add_str != '')
{
?>
<div class="row">
<div class="title_space">
<div class="title-container">
<h1><?php _e('Map',DOMAIN); ?></h1>
</div>
<p><strong><?php _e('Location : '); echo $add_str;?></strong></p>
</div>
<?php if($geo_latitude && $geo_longitude ):?>
<!-- Location Map-->
<div id="location_map">
<div class="google_map" id="detail_google_map_id">
<?php include_once ('google_map_detail.php');?>
</div> <!-- google map #end -->
</div>
<?php endif;?>
</div>
<?php }
}
/* EOF */
And i call using
<!--Custom field collection do action -->
<?php do_action('tmpl_detail_page_custom_fields_collection'); ?>
in single-places.php
Please help me seperate Custom fields from Map and create function for each to call in the single-places.php seperately