我已经找过这个问题,我以前没见过它。如果这是一个重复的问题,我很抱歉。从帖子输入the_loop()ID
我已经完成了一个复杂的查询到我的自定义数据库表,我现在有一个WordPress的帖子ID数组。
现在我想向他们展示the_loop,但我无法做到这一点。我认为重要的是告诉你我正在用ajax显示结果,所有这些功能都在functions.php中(也许这些信息是无关紧要的)。
现在我得到的职位与数据:
function imprimirResultados($resultados = null){
if ($resultados){
echo '<div class="resultados">';
foreach ($resultados as $post_id){
$post = get_post($post_id[0], ARRAY_A);
echo '<div class="post" id="post-'.$post['ID'].'">
<h2><a href="'.$post['guid'].'" rel="bookmark" title="Permanent Link to '.$post['post_name'].'">
'.$post['post_title'].'</a></h2>
<div class="entry">
'.$post['post_excerpt'].'
</div>
</div>';
}
echo '</div>';
var_dump($post);
}else{
echo '<h2 class="center">No encontrado</h2>
<p class="center">Lo sentimos, pero la búsqueda no obtuvo resultados.</p>';
}
}
但它不是一个干净的方法,这样做,我不能使用其他功能,通过the_loop生成的对象()已经有。
---------------------------------编辑------------ -------------------
我离开这里的功能我用:
function resultadosLigeros_callback(){
(...)
$querystr = cargar_ligeros($marca,$modelo,$combustible,$tipo,$anio); //This function generate a MySQL query
$resultados = $wpdb->get_results($querystr, ARRAY_N);
imprimirResultados($resultados, $querystr);//This function is the one I wrote before
die();
}
'the_loop()'不是一个WordPress的功能...你可以显示你的功能,以及它的钩子? – rnevius 2014-12-04 10:43:15