-
在 Wordpress 中,我需要从 myCategory 获取帖子作为博客文章(带有元数据示例日期,发布者等(- 这工作正常,但目前从每个类别中恢复所有帖子
switch ($page_layout) { case "layout-sidebar-single-left": echo '<div class="row fixed">'; echo '<div class="col-220 no-print">'; ewf_setSection('zone-sidebar'); if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-page') ); echo '</div>'; echo '<div class="col-700 last">'; $postTitle = '<h3><a href="' . get_permalink() . '" rel="bookmark">'.get_the_title().'</a></h3>' ; $readMore = '<p class="text-right"><a href="'.get_permalink().'">'.__('Read More', EWF_SETUP_THEME_DOMAIN).'</a></p>'; query_posts('category_name=media&showposts=2'); if (have_posts()) while (have_posts()) : the_post(); echo $postTitle; echo the_content(); echo $readMore; endwhile; echo '</div>'; echo '</div>'; break;
这个怎么样:
query_posts(array('category_name'=>'Category Name','posts_per_page'=>10));
// the Loop
while (have_posts()) : the_post();
the_content( 'Read the full post »' );
endwhile;
<?php $args = array(
'category_name'=>'MyCategory',
'posts_per_page'=>10);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
// display stuff here
endwhile;
这个查询将从名为 MyCategory 的类别中获得 10 篇帖子 - 只需复制/粘贴您当前的代码,即可呈现日期/作者/您在评论部分中已有的任何内容的 HTML。
它是电流回路中的部分