5,
'posts_per_page' => 6,
'orderby' => 'post_date',
'order' => 'DESC',
'post_status' => 'publish',
'ignore_sticky_posts' => true
);
// 查询文章
$query = new WP_Query( $args );
if ($query->have_posts()) {
?>
the_post();
?>
22 ) {
$title = mb_substr( $title, 0, 22 );
$title .= '...'; // 添加省略号
}
$categories = get_the_category();
if ( ! empty( $categories ) ) {
// 获取第一个分类的ID
$category_id = $categories[0]->term_id;
if($category_id == 5){
$category_id = $categories[1]->term_id;
}
}
?>
[]
the_post();
?>
70 ) { // 如果字数超过200字
$excerpt = mb_substr( $excerpt, 0, 70 ); // 截取前200个字符
$excerpt .= '...'; // 添加省略号
}
$categories = get_the_category();
if ( ! empty( $categories ) ) {
// 获取第一个分类的ID
$category_id = $categories[0]->term_id;
if($category_id == 5){
$category_id = $categories[1]->term_id;
}
}
?>
have_posts()) {
$query->the_post();
// 标题
$title1 = get_the_title();
if ( mb_strlen( $title ) > 22 ) {
$title = mb_substr( $title, 0, 22 );
$title .= '...'; // 添加省略号
}
$categories = get_the_category();
if ( ! empty( $categories ) ) {
// 获取第一个分类的ID
$category_id = $categories[0]->term_id;
if($category_id == 5){
$category_id = $categories[1]->term_id;
}
}
?>
-
[]
更多 >>