• This site uses an alternative page template (page-alt) that pulls one category onto one page. I need to get it now to pull a new category onto a new page. It only partly works.

    The page-alt template page uses Custom Fields “pull-category” for this page perfectly:
    http://paintingthecanvas.com/painting-the-canvas/

    All posts using the category of ‘painting the canvas’ get pulled to the page also called ‘painting the canvas’.

    When I made some test posts using a new category of ‘my new york palette’ so that a new page called ‘new york palette’ would also pull just that category, I saw that the page pulled in the name and a link to an archives page, but didn’t show thumbnails or excerpts and post links– like it does for painting the canvas category.

    The code for the alt-page template doesn’t seem to favor the painting the canvas category, so I can’t figure out why it works for one category but not the new one.

    <div id="content-container">
    			<div id="content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php get_template_part( 'content', 'page' ); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    				<hr>
    
    				<div class="cat-list-left">
    
    					<?php
    						// Get the category name from custom field
    						$rb_cat = get_post_meta($post->ID, 'pull-category', true);
    
    					    // Get the ID of a given category
    					    $category_id = get_cat_ID( $rb_cat );
    
    					    // Get the URL of this category
    					    $category_link = get_category_link( $category_id );
    					?>
    
    					<!-- Print a link to this category -->
    					<h1>Posts from
    						<a href="<?php echo esc_url( $category_link ); ?>" title="<?php echo $rb_cat; ?>"><?php echo $rb_cat; ?></a>
    					</h1>
    
    					<?php
    
    					// The Query
    					query_posts( array ( 'category_name' => $rb_cat, 'posts_per_page' => -1 ) );
    
    					echo '<ul class="post-cat">';
    
    					// The Loop
    					while ( have_posts() ) : the_post(); ?>
    
    					<li>
    
    						<?php if( has_post_thumbnail() ) { ?>
    
    						<div class="cat-thumbnail">
    							<?php
    								the_post_thumbnail();
    							?>
    						</div>
    						<?php } ?>
    
    						<a href="<?php echo the_permalink(); ?>">
    							<?php the_title(); ?>
    						</a> 
    
    						<div class="index-name-date cat-meta">
    							By <?php the_author(); ?> on <?php the_date(); ?>
    						</div>
    
    						<div class="content-cat">
    
    						<?php the_excerpt(); ?>
    
    						</div>
    
    						<div class="more-link">
    
    							<a href="<?php the_permalink(); ?>">Read more</a>
    
    						</div>
    
    						<div class="clearme"></div>
    
    					</li>
    					<?php
    						// the_excerpt();
    						// echo ' <p class="postinfo">Written by: ';
    						// the_author_posts_link();
    						// echo 'Posted on '
    						// the_date();
    						// echo 'Categories: '
    						// the_category(', ');
    						// echo '</p>'
    
    					endwhile;
    					echo '</ul>';
    
    					// Reset Query
    					wp_reset_query(); ?>
    
    				</div>

    Any help much much much appreciated!

  • The topic ‘Page template does not pull new category’ is closed to new replies.