我想在Wordpress中创建博客页面,按类别名称查询帖子等...?

时间:2019-04-03 01:51:48

标签: php wordpress

这是我要创建的页面...

<?php
/* Template Name: Blog Page */ 
get_header(); ?>



<div class="home">

<div class="big-post-head">

<?php
$args = array(
  'posts_per_page' => -1,
  'orderby' => 'date',
  'order' => 'DESC',
  'category_name' => 'Cars'
);
$loop = new WP_Query( $args );
?>

<?php while ( $loop->have_posts() ) : $loop->the_post();?>

<?php the_post_thumbnail(); ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>

<?php endwhile; ?>

</div>

<div class="small-posts-head">

<?php
$args = array(
  'posts_per_page' => -5,
  'orderby' => 'date',
  'order' => 'DESC',
  'category_name' => 'Cars'
  'offset' => '1'
);
$loop = new WP_Query( $args );
?>

<?php while ( $loop->have_posts() ) : $loop->the_post();?>

<?php the_post_thumbnail(); ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>

<?php endwhile; ?>


</div>

<?php get_footer(); ?>

这是我第一次尝试使用args或一些​​php编码来执行此操作,因此我可能犯了一些明显的错误。 我遵循了Wordpress教程,并从ehre阅读了一些psot,但仍然无法对其进行整理。

我想做的就是...

首页

  1. 一个重要的帖子,最新的博客。

  2. 最近4条帖子跳过了第一条。

中间页

  1. 一个重要的帖子,最新分类。

  2. 后4条帖子从该类别的第一篇跳过。

低页

  1. 按类别名称列出所有帖子。

0 个答案:

没有答案