WordPress WordPress Theme Development Custom Post Type Templates in WordPress The Portfolio Homepage

Steve Tilus
Steve Tilus
853 Points

None of my images are showing up.

Below is my code I just do not know what is going on. I tried everything. please help.

<?php get_header(); ?>

<section class="row"> <div class="small-12 columns text-center"> <div class="leader">

        <!--- Pull out content for Portfolio page is the purpose of this loop --->

        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
      <h1><?php the_title(); ?></h1>
      <?php the_content(); ?>  
        <?php endwhile;  endif; ?>


    </div>
  </div>
</section>

<?php

$args = array( 'post_type' => 'portfolio_piece' ); $query = new WP_Query( $args );

?>

<section class="row no-max pad"> <?php if($query->have_posts()) : while($query->have_posts()) : $query->the_post(); ?> <div class="small-6 medium-4 large-3 columns grid-item"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('large'); ?></a> </div> <?php endwhile; endif; wp_reset_postdata(); ?> </section>

<?php // loads footer get_footer(); ?>

1 Answer

Carolina Meyer
Carolina Meyer
5,611 Points

Hi Steve! I've taken a look at your code and nothing seems wrong. As a test, I change the post_type in your WP_Query argument to 'post', and that seemed to work.

<?php $args = array( 'post_type' => 'post' ); $query = new WP_Query( $args ); ?>

Are you sure then that the post type has to be portfolio_piece? This will mean there was a custom post type set up for 'portfolio_piece', and it is not using the default WordPress 'post'. I hope this helps