我有一个 WordPress 网站。我正在使用 Ajax 加载我的所有页面和帖子。现在我需要使用 Ajax 加载地图。但是,它没有加载。刷新页面后,地图正在加载。我对此有疑问。
这是来自 function.php 文件的代码
$html.= '<li class="image_dsp '.$carousel_class.'" style="'.($count==1 ? "display:block;" : "display:none;").'" id="asset-tile-'.$p->ID.'">';
//Check the ID on contact page
if($p->ID==532){
$html.= '<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Sidra+Tower,+Dubai&sll=25.107596,55.179241&sspn=0.011289,0.021136&ie=UTF8&hq=&hnear=Sidra+Tower&t=m&ll=25.107518,55.179348&spn=0.027202,0.036478&z=14&output=embed"></iframe>';
}
$html.= '</li>';
}
print $html
我也使用了插件。并在我的页面中使用简码。但是,它有同样的问题。
完整的功能代码在这里
<div class="single">
<?php
if(count($get_posts)>0){
$html.= '<div style="float:left; width:512px;" id="ajax_content">';
$html.= '<ul class="thumbs">';
foreach($get_posts as $p){
if (has_post_thumbnail()){ //Edit by Yesh
$feat_image = wp_get_attachment_url(get_post_thumbnail_id($p->ID));
$first_image = $count==1 ? ' first_image' : '';
$carousel_class = "section-asset-photo {sort: 'type-00".$count."-000' } tile";
$html.= '<li class="image_dsp '.$carousel_class.'" style="'.($count==1 ? "display:block;" : "display:none;").'" id="asset-tile-'.$p->ID.'"><a href="http://www.zaha-hadid.com/wp-content/files_mf/dsm5.jpg" target="_blank" class="slideshow"><img class="slickr-post'.$first_image.'" src="'.$feat_image.'"/></a></li>';
// set up image contents
if($count==1){
$default_active = $p->ID;
$slider_content = $p->post_content;
$slider_content = apply_filters('the_content', $slider_content);
//$slider_content = str_replace(']]>', ']]>', $slider_content);
$slider_content = do_shortcode($slider_content);
}
if(count($get_posts)>1){
$navigation.= '<a href="#" id="'.$p->ID.'" class="load-page'.($default_active==$p->ID ? ' activeSlide' : '').' '.$p->ID.'">'.$count.'</a>';
}
$pathinfo = pathinfo($feat_image);
$big_image = $pathinfo['dirname'].'/'.$pathinfo['filename'].'_big.'.$pathinfo['extension'];
$gallery_li[$p->ID] = array(
'medium_image'=>$feat_image,
//'large_image'=>'http://www.zaha-hadid.com/wp-content/files_mf/cache/th_65d1300db123ce22f6e2569fb36764f8_dsm5.jpg'
);
$js_script.= 'myimages['.$post_id.']['.($count-1).'] = "'.$p->ID.'";';
$count++;
}else{
$carousel_class = "section-asset-photo {sort: 'type-00".$count."-000' } tile";
// set up image contents
if($count==1){
$default_active = $p->ID;
$slider_content = $p->post_content;
$slider_content = apply_filters('the_content', $slider_content);
// $slider_content = str_replace(']]>', ']]>', $slider_content);
$slider_content = do_shortcode($slider_content);
}
$html.= '<li class="image_dsp '.$carousel_class.'" style="'.($count==1 ? "display:block;" : "display:none;").'" id="asset-tile-'.$p->ID.'">';
// Check the ID on contact page
if($p->ID==532){
$html.= '<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Sidra+Tower,+Dubai&sll=25.107596,55.179241&sspn=0.011289,0.021136&ie=UTF8&hq=&hnear=Sidra+Tower&t=m&ll=25.107518,55.179348&spn=0.027202,0.036478&z=14&output=embed"></iframe>';
}
$html.= '</li>';
$count++;
}
}
$html.= '</ul></div>';
$html.= '<div class="project_desc">';
$html.= $slider_content;
$html.= '</div>';
$html.= '<div class="smooth_nav">';
$html.= $navigation;
$html.= '</div>';
}
print $html;