views:

40

answers:

2

Hi,

Please at first let me explain my question. I use wordpress to create web sites for flash games, so I don't have certain page for post's. I add each game by

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

and u can see it's not the regular post for wordpress. I try to use this code from codex:

<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>

I think it really have to works for posts, but in such case I try to change post for games, try many ways, but don't sucseed yet. Could anyone tell me what I have change in this code? i think that promblem in the begining with 'have post' and 'the loop'. Thanks.

+1  A: 

I hope this will help. This is from my WordPress custom post type (loop):

<?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();?>

Umbrovskis.com
Thanks, but I can't apply your loop to my code, maybe because of my php low skills or smth else, but I have a errors incategory page. I try to change your 'name_of_clients' and 'company' for my category, but it wasn't help. Thanks, anyway!
glazsasha
+1  A: 

Just found one mistake: in_category('') MUST be filled with category ID in slug. http://codex.wordpress.org/Function_Reference/in_category#Parameters

Correct would be in_category('some-game-cat-slug')

plus worth to read http://new2wp.com/noob/query_posts-wp_query-differences/

Umbrovskis.com