help with code for custom post category
-
I know this topic has been covered a lot, but the code in the template I am using isn’t exactly the same as is covered in other forum posts, so looking for a little help.
I am trying to show only the category “American” from my Restaurants custom post list on my AMERICAN page. As it is now – the page is displaying ALL of the restaurants, not just the category I want. Here is the code I am using in my template, with my attempt at the category callout in bold:
<?php /** * Template Name: Restaurants List American * */ ?> <?php get_header(); ?> <?php $page_width = get_post_meta(get_the_ID(), 'wpl_sidebar_option', true); ?> <div id="main" class="site-main container_12"> <div id="primary" class="content-area ml <?php if ( $page_width != 'off' ) { echo 'grid_9'; } else { echo 'grid_12'; } ?>"> <div id="content" class="site-content"> <?php // Display the default content if ( $post->post_content != '' ) { ?> <?php while ( have_posts() ) : the_post(); ?> <article class="single"> <div class="entry-content"> <?php the_content(); ?> </div> <div class="clear"></div> </article> <?php endwhile; } // End displaying the default content ?> <?php $args = array( 'post_type' => 'post_restaurants','post_status' => 'publish', 'posts_per_page' => ot_get_option('wpl_restaurant_per_page'), 'paged'=> $paged); ?> <strong> <?php query_posts('category_name=American'); ?></strong> <?php $wp_query = null; ?> <?php $wp_query = new WP_Query( $args ); ?> <?php if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <!-- Article --> <article id="post-<?php the_ID(); ?>" <?php post_class('list'); ?>> <?php if ( has_post_thumbnail() ) {?> <figure> <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('small-thumb'); ?> </a> </figure> <?php } ?> <h1 class="entry-header"> <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h1> <div class="short-description"> <p><?php echo wplook_short_excerpt(ot_get_option('wpl_restaurant_excerpt_limit'));?></p> </div> <div class="entry-meta"> <a class="read-more-button fleft" href="<?php the_permalink(); ?>" title="<?php _e('Read more', 'wplook'); ?>"><?php _e('Read more', 'wplook'); ?></a> </div> <div class="clear"></div> </article> <?php endwhile; wp_reset_postdata(); ?> <?php else : ?> <p><?php _e('Sorry, no restaurants matched your criteria.', 'wplook'); ?></p> <?php endif; ?> <?php wplook_content_navigation('postnav' ) ?> </div> </div> <!-- Right Sidebar --> <?php if ($page_width != 'off') { ?> <div id="secondary" class="widget-area grid_3"> <?php get_sidebar('restaurants'); ?> </div> <?php } ?> <div class="clear"></div> </div><!-- #main .site-main --> <?php get_footer(); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘help with code for custom post category’ is closed to new replies.