2011-12-14 90 views
0
  1. 在WordPress我需要得到的職位形成myCategory的博客文章(與元數據例如日期,張貼等等) - 這是工作不錯,但目前帶回所有的職位從每個類別我怎樣才能從一個特定類別的10個職位(myCategory)在WordPress

     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; 
    

回答

1

如何:

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; 
+0

這從類別帶回的職位,但更多的標籤和文章的標題內的部分沒有多頭指向完整的文章。該帖子使用標籤創建摘錄。 – Grundizer 2011-12-14 12:11:47

0
<?php 
//get allthe posts of relevant category 
get_posts = get_posts(array('posts_per_page' => 10, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'category_name')); 
//loop start 
foreach($get_posts as $post): 
echo $post->post_title; 
echo $post->post_content; 
endforeach; 
//loop end 
?> 
0
<?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的日期/作者/不管你已經在評論部分您當前的代碼。

這是你的電流回路

相關問題