$cat_id, // 分类ID
'posts_per_page' => 1, // 每页显示的文章数量
'orderby' => 'date', // 按日期排序
'order' => 'ASC', // 升序
);
$cur_post = get_posts($args);
setup_postdata($cur_post);
if (count($cur_post)>0) {
$content = $cur_post[0]->post_content; // 文章内容
echo $content;
} else {
echo '文章不存在';
}
// 释放查询结果
wp_reset_postdata();
}
// 加盟解答
if($cat_id == 16){
// 假设你已经在WordPress环境中,并且有分类ID $category_id
$category_id = $cat_id; // 替换为你的分类ID
// 获取分页参数
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// 查询参数
$args = array(
'cat' => $category_id, // 分类ID
'posts_per_page' => 10, // 每页显示的文章数量
'paged' => $paged
);
// 查询文章
$query = new WP_Query($args);
$index = 0 + ($paged-1) * 10;
echo '
';
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
// 在这里编写你的文章列表
$post_id = get_the_ID(); // 获取文章ID
$index = $index + 1;
$content = get_post_field('post_content', $post_id);
?>
';
}
// 加盟申请
if($cat_id == 17){
include 'commentForm.php';
}
?>