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 believe this problem to be quite simple but can't seem to get my head around how to solve it.

So I'm pulling in all the category with posts in using wp_list_categories();

My problem is when I click through it pulls in the correct posts but, I want it to pull in the correct posts and still have wp_list_categories links at the top so someone can switch between the posts.

So really all that needs to change is that when you click a category link the relevant posts get pulled looking the same as there displayed now.

I know this is going to involve conditions and maybe some new queries written - I want to try and do this in the most robust way possible.

Link to the page

code at the moment generating this page.

<?php
/*
 *  * Template Name: Case Studies
 */
?>
<?php global $up_options, $post, $paged, $wp_query; ?>
<?php get_header(); ?>
<div id="bodywrapper">
        <?php $args = array(
            'title_li'           => __( '' ),
        ); ?>
        <div class="category-list"><?php wp_list_categories($args); ?></div>
    <div style="height: 25px"></div>

    <div id="content"> 
        <h1>Case Studies</h1>

     <?php
    $start = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
      $wp_query->query('posts_per_page=5&post_type=post'.'&paged='.$paged);
        while ($wp_query->have_posts()) : $wp_query->the_post(); 
                    ?>
                    <div id="post-<?php the_ID(); ?>" class="post">
                        <a href="<?php the_permalink() ?>">
                            <?php if (has_post_thumbnail()) { ?>
                                <?php the_post_thumbnail('thumbnail'); ?>
                            <?php }?>
                        </a>
                        <h1 class="post-title"><a href="<?php  echo get_post_meta($post->ID, 'lj_file_url', true) ?>" title="<?php the_title(); ?>"> <?php the_title(); ?></a></h1>
                        <div class="post-entry">
<a href="<?php  echo get_post_meta($post->ID, 'lj_file_url', true) ?>" title="Download pdf <?php the_title(); ?>"> <img src="http://www.integra-av.co.uk/wp-content/uploads/2012/04/pdflogo.png" alt="" class="alignleft"/></a>
                            <?php the_excerpt(); ?>
                        </div>
                    </div>
                <?php endwhile; ?>
                <div class="clear">
                    <?php wpld_pagenavi(); ?>
                </div>

<br/><br/><br/><br/><br/><br/>

<p style="text-align: center;"><span style="font-size: 35px;"><span style="color: #2788e4;">Secure Solutions</span></span></p>
    </div>
    <?php get_footer(); ?>
share|improve this question

1 Answer 1

Refer to the Template Hierarchy. You'll need to create a category.php template file, since the category archive index is what gets displayed when clicking a category link in the wp_list_categories() output.

share|improve this answer
    
So it automatically displays a file named that - if thats correct then this is fairly simple for me to construct. –  dannyw24 Oct 15 '13 at 16:36

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.