Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a problem - I want display posts from current category on page with custom template. I write something like this:

<?php include 'header.php' ?>

<div class='content'>

        <?php if (have_posts()) : ?>
    <div class='blues2'>
        <div class='tekst'>
            <p><?php echo get_the_title($post->post_parent);?>  - <span class='podkategoria'><?php the_title(); ?></span></p>
        </div>  
    </div>
    <?php
            $catid = get_query_var('cat');  
            $args = array(
            'posts_per_page' => 2,
            'category__in' => $catid,
            'paged' => get_query_var('paged')
            );
            query_posts( $args );

        ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class='przepis'>
        <div class='icons'>
            <?php if ( has_post_thumbnail()) : ?>
               <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
                    <?php the_post_thumbnail( array(218,181) ); ?>
                </a>
            <?php endif; ?>
        </div>
        <div class='tresc-main'>
        <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a></h2>
            <div class='wnetrze'>   
                <?php
                    global $more;
                    $more = 0;
                    ?>
                <?php the_content(''); ?>
            </div>
        </div>
        <div class='pozostale'>
            <p><span class='podkategoria'><?php $category = get_the_category(); echo $category[0]->cat_name; ?></span></p>
            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >>zobacz pozostaƂe produkty</a>
        </div>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
</div>

<?php include 'footer.php' ?> 

But it doesn't work. Where is the problem?

share|improve this question
    
so this is a page post type? how are you associating it to a category? –  Milo Sep 12 '13 at 18:50
    
What exactly does't work ? What are you seeing ? And what kind of page is this ? –  Alex Dumitru Sep 12 '13 at 18:59
    
don't alter the main loop, use WP_Query(); or get_posts(); instead of query_posts(); –  Anjum Sep 12 '13 at 19:23
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.