我在我的网站上有一个名为Work(使用Work.php页面模板)的页面,设置为我的首页,我想在这里显示最近十篇文章的列表,自定义类型为portfolio。以下是我目前的代码:
<?php $the_query = new WP_Query( array( \'post_type\' => \'portfolio\', \'posts_per_page\' => 10 ) ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<section id="post-<?php the_ID(); ?>" <?php post_class( \'portfolio-post\' ); ?>>
<header>
<h2><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<time datetime="<?php the_time(\'Y-m-d\') ?>" pubdate><?php the_time(\'F jS, Y\') ?></time>
</header>
</section>
<?php endwhile;?>
问题是,尽管我在wordpress的后端创建了两篇此类帖子,但该页面上什么也没有显示。当一个被点击时,我想被带到/work/the_post_i_clicked/
. 我必须承认我在这里有点困惑。任何帮助都将不胜感激。