0

I am trying to pull posts with the post-format of "quote" on my sidebar. I'm getting the code to spit out the else statement but that's about it so far. I am working in the roots theme if that helps at all. Let me know if I can show anymore code that might help you help me :). Thanks.

<div class="sidebar-quote">

  <?php

  $quote = array(
            'posts_per_page' => 1,
            'post_type' => 'post',
            'tax_query' => array(
                array(
                    'taxonomy' => 'post-format',
                    'field' => 'slug',
                    'terms' => array( 'post-format-quote' )
                )
            )
        );
   ?>

  <?php
  $the_query = new WP_Query( $quote ); ?>

  <?php if ( $the_query->have_posts() ) : ?>

  <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

  <?php get_template_part('templates/content', 'quote'); ?>

 <?php endwhile; ?>

 <?php wp_reset_postdata(); ?>

<?php else:  ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
2
  • I would start by double-checking that you have at least 1 published post with the quote format.
    – mrwweb
    Aug 26 '14 at 22:21
  • Always a good reminder. Definitely have some in there @mrwweb
    – Waymond
    Aug 26 '14 at 22:29
0

I'm a noob. I named the Taxonomy wrong... It's

post_format

not

post-format
1
  • Why did I get voted down for correcting myself?
    – Waymond
    Sep 9 '14 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.