drfb52000 2012-12-29 00:30
浏览 37

查询未加载get_post_meta数据

The function below is used to load my custom post type posts. The problem is that it isn't loading the get_post_meta data. I have this in my functions.php file. Do I need something added to the get_post_meta since it's in the functions file?

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');
  • 写回答

1条回答 默认 最新

  • dongyu1983 2012-12-29 03:02
    关注

    add this to the function global $post;

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器