• Evening all.

    Hope this is the right place to post this but I need a little help. I have the following code which brings in a list of portfolios, and places them on a page in a grid format. At present the code brings in all the portfolio types (of which there are 3, divided into different categories). Is there a way I can edit the code so that I can bring in just one category type?

    I have tried the following:

    <?php query_posts( array( 'post_type' => 'myportfoliotype', 'category_name' => 'news','paged' => $paged, 'posts_per_page' => 12));
    
    		if ( have_posts() ) : while ( have_posts() ) : the_post();?>

    but it displays a blank page.

    If I remove:

    ', 'category_name' => 'news'

    it returns a page will all the categories listed.

    I would be greatful if anyone could help.

    Many thanks

    The full code is:

    <?php
    /*
    Template Name: Modular Gallery
    */
    ?>
    <?php get_header(); ?>
    
    <div class="container container_alt">
    Modular Gallery
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    
    <div id="folio-wrap">
    
    	<ul id="portfolio-list" class="centerrow"> 
    
            <?php query_posts( array( 'post_type' => 'myportfoliotype', 'category_name' => 'news','paged' => $paged, 'posts_per_page' => 12));
    
    		if ( have_posts() ) : while ( have_posts() ) : the_post();?>
    
                <?php
    				$large_image =  wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'fullsize', false, '' );
    				$large_image = $large_image[0];
    				$another_image_1 = get_post_meta($post->ID, 'themnific_image_1_url', true);
    				$video_input = get_post_meta($post->ID, 'themnific_video_url', true);
                ?>
    
                <li id="post-<?php the_ID(); ?>" class="centerfourcol item_full">
    
                    <span class="imgwrap">
    
                        <?php the_post_thumbnail('folio',array('title' => "")); ?>
    
                        <a class="hoverstuff-zoom" rel="prettyPhoto[gallery]" href="<?php if($video_input) echo $video_input; else echo $large_image; ?>"><i class="icon-zoom-in"></i></a>
                        <a class="hoverstuff-link" href="<?php the_permalink(); ?>"><i class="icon-link"></i></a>
    
                    </span>	
    
                    <div style="clear:both"></div>
    
                    <h3><a href="<?php the_permalink(); ?>"><?php echo short_title('...', 6); ?></a></h3>
    
                    <?php echo themnific_excerpt( get_the_excerpt(), '290'); ?>
    
                </li><!-- #post-<?php the_ID(); ?> -->
    
    		<?php endwhile; endif; ?> 
    
       </ul>	
    
            <div class="clear"></div>
    
    		<div class="pagination"><?php pagination('?', '?'); ?></div>
    
    	<?php wp_reset_query(); ?>
    
    </div>
    
    </div>
    
    <?php get_footer(); ?>

  • The topic ‘Editing a loop to bring in one category type.’ is closed to new replies.