• Resolved uspinnak

    (@uspinnak)


    Is there a general way for me to be able to call each category archive for each category page? Currently when I click on an archive page I get all my most recent posts for all categories rather then the one category that I am looking for. EX: If I click on my photos category I get posts from all of my categories. This is the code I am currently using.

    if (have_posts()) : query_posts('posts_per_page=12');
    while (have_posts() && $postNumber < 6) : the_post();$do_not_duplicate = $post->ID; ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • Where is that code from? What template file? Do you have a category.php template? If not, try creating one by copying your archive.php file.

    Thread Starter uspinnak

    (@uspinnak)

    That code is from archive.php. I do not have a category.php. If I create one how would I link to it rather then the archives page.

    You don’t need to link to it. WP will use the category.php template file every time someone clicks on a category link in your site.

    Thread Starter uspinnak

    (@uspinnak)

    I tried that and it still pulls content from all categories instead of just one. I am missing something?

    <?php get_header(); ?>
    <div class="breadcrumb">
    <?php
    if(function_exists('bcn_display'))
    {
    	bcn_display();
    }
    ?>
    </div>
    
    <div id="content">
    
    <div class="minipost">
    
    <?php if (have_posts()) : query_posts('posts_per_page=12') ?>
    <?php while (have_posts() && $postNumber < 6) : the_post();$do_not_duplicate = $post->ID ?>
    
    <div class="hentry">
    <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php $screen = get_post_meta($post->ID,'screen', true); ?>
    <img src="<?php echo ($screen); ?>" width="310" height="100" alt=""  />
    
     <?php the_excerpt(); ?>
    </div>
    <div class="meta">
    	<div class="timer"><?php the_time('j F Y') ?></div>
    	<div class="more"> <a href="<?php the_permalink() ?>">Read More</a></div>
    </div>
    <?php $postNumber++; endwhile; ?>
    </div>
    
    <div class="minipost">
    
    <?php
    while (have_posts() && $postNumber < 12) : the_post();$do_not_duplicate = $post->ID; ?>
    
    <div class="hentry">
    <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php $screen = get_post_meta($post->ID,'screen', true); ?>
    <img src="<?php echo ($screen); ?>" width="310" height="100" alt=""  />
    
     <?php the_excerpt(); ?>
    </div>
    <div class="meta">
    	<div class="timer"><?php the_time('j F Y') ?></div>
    	<div class="more"> <a href="<?php the_permalink() ?>">Read More</a></div>
    </div>
    <?php $postNumber++; endwhile; endif; ?>
    
    </div>
    
    <div class="navigation">
            <?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>
    
    		</div>
    </div>
    
    <?php get_sidebar(); ?>
    <div class="clear"></div>
    <?php get_footer(); ?>

    Please don’t post huge chunks of code here. For larger blocks of code, use the WordPress pastebin and post the pastebin url here. It makes life easier for everyone.

    Try this instead.

    Thread Starter uspinnak

    (@uspinnak)

    Sorry about that. I will make sure to use that next time. That did work for me I just need to edit it now for my layout thanks.

    No problem. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘PhP Call categories for archives’ is closed to new replies.