2010-10-18 40 views
1

請首先讓我解釋我的問題。我使用wordpress爲Flash遊戲創建網站,所以我沒有特定的發佈頁面。我通過WordPress的:類別頁不適用於職位的

<code> 
    post-new.php?post_type=game 
</code> 

添加每個遊戲,你可以看到它不是WordPress的普通帖子。 我嘗試從手抄本使用此代碼:

<code> 
    <?php if (have_posts()) : while (have_posts()) : the_post(); 
    $i = 0; 
    $loop = new WP_Query(array('post_type' => 'game', 'post_per_page' => 5)); 
    while ($loop->post_type()) : $loop->game(); 
    ?> 
</code> 
<code> 
    <?php if (in_category('')) { ?> 
       <div class="post-cat-three"> 
    <?php } else { ?> 
       <div class="post"> 
    <?php } ?> 
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 

    <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small> 

    <div class="entry"> 
     <p>Category: <?php single_cat_title(); ?></p> 

    </div> 

    <p class="postmetadata">Posted in <?php the_category(', '); ?></p> 
</code> 

我認爲這真的要上崗的作品,但在這種情況下,我嘗試改變後的遊戲,嘗試了很多辦法,但還沒有sucseed。 任何人都可以告訴我在這段代碼中有什麼變化嗎? 我認爲在'有帖子'和'循環'開始的前奏。 謝謝。

回答

1

我希望這會有所幫助。這是我的WordPress自定義文章類型(環路):

<?php query_posts('post_type=clients&showposts=1000'); 

if (have_posts()) : while (have_posts()) : the_post(); $nameofclient = get_post_meta($post->ID,'name_of_client',true); $clientcompany = get_post_meta($post->ID,'company_of_client',true);?> <div <?php post_class();?> id="ka-<?php the_ID(); ?>"> <h2 class="categorytitle"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?><p class="ats_autors">/ <?php if($nameofclient): echo '<span class="client">'.$nameofclient.'</span>'; endif; if($clientcompany): if($nameofclient){echo ', ';} echo '<span class="client-company">'.$clientcompany.'</span>'; endif; ?></p></div><?php endwhile; endif;wp_reset_query();?>

+0

謝謝,但我不能在您的循環應用也許是因爲我的代碼,我PHP低技能或其他人,但我有一個錯誤類別頁面。我嘗試將您的'name_of_clients'和'company'更改爲我的類別,但這沒有幫助。不管怎麼說,還是要謝謝你! – glazsasha 2010-10-18 13:25:39

+0

這是用於「自定義的帖子類型」,這與帖子類似,正如我從您的代碼中瞭解的。 是的,這不適用於「類別」。 – 2011-07-06 06:44:01

相關問題