WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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>
            $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) ); ?>
            <?php endif; ?>
        <div class='tresc-main'>
        <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a></h2>
            <div class='wnetrze'>   
                    global $more;
                    $more = 0;
                <?php the_content(''); ?>
        <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>
    <?php endwhile; ?>
    <?php endif; ?>

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

Your Answer


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

Browse other questions tagged or ask your own question.