Images are not showing in my blog
-
Here is my code for the blog, but the images attached to every post are not showing.
Can anyone help me?<article> <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $args = array( 'posts_per_page' => 3, 'cat' => 7, 'paged' => $paged, ); var_dump($args); $wp_query->query( $args ); while ( $wp_query->have_posts() ) : $wp_query->the_post(); $post_id = get_the_ID(); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php the_time('F jS, Y') ?></h2> <?php $args = array( 'post_type' => 'attachment', 'order' => 'ASC', 'numberposts' => 1, 'post_mime_type' => 'image', 'post_parent' => $post_id ); var_dump($args); $images = get_posts($args); if ($images) { foreach ($images as $image) { echo wp_get_attachment_image( $image->ID, 'thumbnail' ); } } ?> <p> <?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,45); ?> </p> <p class="read_more">Read the full post <a href="<?php the_permalink(); ?>">here</a></p> <?php endwhile; ?> <?php if ( $paged > 1 ) { ?> <nav id="nav-posts"> <div><?php next_posts_link( ' Previous' ); ?></div> <div><?php previous_posts_link( 'Next' ); ?></div> </nav> <?php } else { ?> <nav id="nav-posts"> <div><?php previous_posts_link( 'Previous ' ); ?></div> </nav> <?php } ?> <?php wp_reset_postdata(); ?> <?php $wp_query = null; $wp_query = $temp; ?> </article>
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Images are not showing in my blog’ is closed to new replies.