2012-12-29 19 views
0

以下函數用於加載我的自定義帖子類型帖子。問題在於它沒有加載get_post_meta數據。我在我的functions.php文件中有這個。我需要添加到get_post_meta的東西,因爲它在函數文件中?查詢未加載get_post_meta數據

function get_latest_post(){ 
global $wpdb; 

$num=$_POST['numposts']; 
$id = $_POST['id']; 
$id = split('page',$id); 
$id = str_replace('/','',$id[1]); 
if($id!=0) 
{ 
$offst = $id*$num-$num; 
}else $offst=0; 
$wp_query = new WP_Query(); $wp_query->query('post_type=video_posts&orderby=date&posts_per_page='.$num.'&offset='.$offst); 
if($wp_query->have_posts()) : $i = 1; while ($wp_query->have_posts()) : $wp_query->the_post();?> 
<?php $embeds = get_post_meta($post->ID, 'rm_video_embed_code'); ?> 
<?php $thumbnail_id = get_the_post_thumbnail($post->ID); 
preg_match ('/src="(.*)" class/',$thumbnail_id,$link); 
if(!empty($thumbnail_id)) { 
$image_path = thumbGen($link[1],190,0,"crop=1&halign=center&valign=center&return=1"); 
$image_all = get_bloginfo('url').$image_path; 
$my_image = array_values(getimagesize($image_all)); 
list($width, $height, $type, $attr) = $my_image; 
} 
?> 
<div class="pop_<?php echo $i; ?>" style="display:none;"><div class="bClose"></div> 
<?php foreach($embeds as $embed) { echo $embed; }?> 
</div> 

<?php if(has_post_thumbnail()) : ?> 
<li><a href="javascript:void(0);" class="video_popup_<?php echo $i; ?>" title="<?php the_title(); ?>"> 
<div class="video_title"><?php the_title(); ?></div> 
<div class="video_description"><?php the_content(); ?></div> 
<div><img src="<?php echo $image_path; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" /></div> 
<div class="clear"></div> 
</a></li>  
<?php endif; ?> 
<?php $i++; endwhile; ?> 
<?php endif; //wp_reset_query();  
if((1==1)===FALSE){ 
echo "Oops! System error!"; 
} 
else { 
} 
die(); 
} 
add_action('wp_ajax_get_latest_post', 'get_latest_post'); 
add_action('wp_ajax_nopriv_get_latest_post', 'get_latest_post'); 
+0

。怎麼了? '$ embeds'是否會以預期的不同值結束?腳本是否停止運行?你有錯誤嗎?具體發生了什麼? –

+0

沒有數據加載。它什麼都不返回。如果我回應它,​​則不會顯示任何內容。 – jonthoughtit

+0

你會發生什麼'var_dump()'它?你真的不應該使用'echo'來進行調試。您可能需要查看該功能本身,以查看出錯的位置。 –

回答

0

它添加到你的「它不加載qet_post_meta數據」意味着什麼功能global $post;