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.

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

    $start = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
        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 }?>
                        <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(); ?>
                <?php endwhile; ?>
                <div class="clear">
                    <?php wpld_pagenavi(); ?>


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

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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