2012-12-24 126 views
0

我已經創建了自定義帖子類型,現在我想要顯示沒有自定義帖子類型的所有帖子。我有顯示自定義後這樣要顯示具有自定義帖子類型的帖子

$args = array(
     'post_type' => 'badge', 
    ); 
    // The query itself 
    $sb_user_query = new WP_Query($args); 
    // The loop 
    while ($sb_user_query->have_posts()) : $sb_user_query->the_post(); 
     $badge_id = $sb_user_query->post->ID; 
     $badge_title = get_the_title(); 
     $author = get_the_author(); 
     $author_id = get_the_author_ID(); 
     $badge_image_small = get_the_post_thumbnail($badge_id, array(16,16)); 
     $post_data = get_post_meta($badge_id, '_metabox', true); 
     $comment_data = get_post_meta($badge_id, '_comments', true); 
     echo $author.$badge_image_small; 
    endwhile; 

現在我想沒有「徽章」後型號來顯示所有的職位類型。我該怎麼做,請幫助我。

回答

0
I think below code will give u the idea. 

<?php 
    $type = 'badge'; 
    $args=array(
    'post_type' => $type, 
    'post_status' => 'publish', 
    'posts_per_page' => -1, 
    'caller_get_posts'=> 1 

$my_query = null; 
$my_query = new WP_Query($args); 
if($my_query->have_posts()) { 
    while ($my_query->have_posts()) : $my_query->the_post(); 
    global $post; 
    $badge_id = $post->ID; 
    $badge_title = get_the_title(); 
    $author = get_the_author(); 
    $author_id = get_the_author_ID(); 
    $badge_image_small = get_the_post_thumbnail($badge_id, array(16,16)); 
    $post_data = get_post_meta($badge_id, '_metabox', true); 
    $comment_data = get_post_meta($badge_id, '_comments', true); 
    echo $author.$badge_image_small; 

endwhile; 
} 
wp_reset_query(); // Restore global post data stomped by the_post(). 
?> 
相關問題