php - Display Wordpress Posts as gallery with title -
for project working on have been trying set wordpress post loop on subpage woould display posts thumbnail image posts title underneath. not posts listet rather 1 link referring subpage gallery should on. me out please?
here code saved page-gallery.php in childthemes folder:
<?php get_header(); ?> <div id="main" class="wrapper"> <?php global $query_string; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="gallery_image_container"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <div class="gallery_image_thumb"> <?php the_post_thumbnail('thumbnail'); ?> </div> <h2><?php the_title(); ?></h2> </a> </div> <?php endwhile; else : ?> <p><?php _e( 'sorry, no posts matched criteria.' ); ?></p> <?php endif; ?> <?php get_footer(); ?>
the css following:
.gallery_container { position: relative; float: left; width: 150px; height: 150px; border: 10px solid #ccc; margin: 20px; }
i have created jsfiddle tell want achieve in end: http://jsfiddle.net/vdpktlxr/
your code echos content of page "page-gallery.php" . displaying posts need use loop, example this:
<?php // query query_posts( $args ); // loop while ( have_posts() ) : the_post(); echo '<li>'; the_title(); echo '</li>'; endwhile; // reset query wp_reset_query(); ?>
you can find more info here
Comments
Post a Comment