HiI进行了一个sql查询,该查询根据我选择的参数获取多篇文章。我正在显示这些帖子,但是wordpress内部的页面没有任何作用。它显示有更多的页面,但当我选择页码时,它会显示与之前相同的结果。这很有意义,因为它可能会再次运行sql查询。我正在使用WordPress和BuddyPress。如何在这些查询结果之间分页?
更新:这是我使用的代码
$sql = "SELECT post_title, post_date, post_excerpt, guid, ID FROM wp_posts,wp_term_taxonomy, wp_terms, wp_term_relationships WHERE (post_status = \'publish\' or post_status = \'inherit\') and wp_term_taxonomy.term_taxonomy_id = ".$cat." and wp_posts.ID = wp_term_relationships.object_id and wp_terms.term_id = wp_term_taxonomy.term_taxonomy_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and wp_term_taxonomy.taxonomy = \'category\' ORDER by post_date DESC";
$matching_posts = $wpdb->get_results($sql,OBJECT);
<?php if ( have_posts() ) : ?>
<?php foreach ($matching_posts as $post): ?>
<?php setup_postdata($post);
然后我显示的信息,我想像标题。