我想把它分成两个功能

时间:2013-09-06 作者:luckyrajiv

我将在下面添加的代码用于自定义帖子类型的自定义字段和自定义帖子类型的GMap。

目前这两个都是由该函数拉取的。

我想把两者分开。一个用于自定义字段,一个用于映射。

代码如下:

<小时>

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 */
我使用

        <!--Custom field collection do action -->
        <?php do_action(\'tmpl_detail_page_custom_fields_collection\');  ?>

在单个位置。请帮助我将自定义字段从映射中分离出来,并为每个字段创建函数,以便在单个位置调用。php单独

1 个回复
SO网友:Vinod Dalvi

您可以使用以下代码将其分为两个函数:

<?php

add_action(\'tmpl_detail_page_custom_fields_collection\',\'custom_fields_colletion\');

/*
Name : custom_fields_colletion
Desc : Return the custom fields collection for detail/single page
*/
function custom_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>";
          }
   }
}

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;
}


add_action(\'tmpl_detail_page_gmap_collection\',\'gmap_colletion\');

/*
Name : gmap_colletion
Desc : Return the gmap collection for detail/single page
*/
function gmap_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){
$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>";
  }
}

    $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 }

}
?>
您可以使用以下方式调用它:

<!--Custom field collection do action -->
<?php do_action(\'tmpl_detail_page_custom_fields_collection\');  ?>

<!--GMap collection do action -->
<?php do_action(\'tmpl_detail_page_gmap_collection\');  ?>

结束

相关推荐

Functions.php中的帖子ID错误

我试图在我的函数中执行以下代码。php更改我的wordpress博客的标题。function filter_pagetitle($url) { global $wp_query; $the_post_id = $wp_query->post->ID; $the_post_data = get_post($the_post_id); return $the_post_da