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.

Hi,everyone.Sorry my bad English,and I hope you can understand what I mean.

In my WordPress theme, I craeted a Custom post type named "Portfolio", Because I want show the single category with list of the post title. So I put this code in the index.php

$categories = get_categories();
foreach ($categories as $cat) {

    $post_num = get_option('wpd_index_post_num');

    query_posts("showposts=$post_num&cat=$catid"); ?>

    <div class="accordion">
        <span class="cat_n"><?php single_cat_title(); ?></span>
        <div class="cat_info">
        <span class="archive_more"><a href="<?php echo get_category_link($catid);?>" rel="bookmark" title="more">More</a></span>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <li><h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                <em class="date"><?php the_time('m-d'); ?></em></li>

    <?php endwhile; ?>
    <?php endif; ?>
<?php }?>

Now the questions is how to display category with post title in Portfolio ? some code like this:

<div class="accordion">
<span class="cat_n">Portfolio Category Title</span>
<div class="cat_info">
    <span class="archive_more">
        <a href="http://category-link" rel="bookmark" title="more">More
    <li><h2><a href="#" title="post-title">post1 in the Portfolio Category 1</a></h2></li>
    <li><h2><a href="#" title="post-title">post2 in the Portfolio Category 1</a></h2></li>
    <li><h2><a href="#" title="post-title">post3 in the Portfolio Category 1</a></h2></li>
    <li><h2><a href="#" title="post-title">post4 in the Portfolio Category 1</a></h2></li>
    <li><h2><a href="#" title="post-title">post5 in the Portfolio Category 1</a></h2></li>

share|improve this question
Could you please explain more in detail what you are trying to achieve? Why is this code in index.php and not in archive-portfolio.php or in a category archive page? Or is it an additional loop? –  Fränk Apr 27 '13 at 11:44
add comment

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.