admin管理员组文章数量:1391982
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=".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(); ?>
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
asked Oct 15, 2013 at 16:14
dannyw24dannyw24
4511 gold badge6 silver badges16 bronze badges
1 Answer
Reset to default 0Refer 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.
本文标签: categoriesDisplaying different posts Via wplistcategories()
版权声明:本文标题:categories - Displaying different posts Via wp_list_categories() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744680827a2619395.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论