php - How to display custom post type as a gridview using wordpress code -
i have custom post type "events" , want display events in table of 3 columns pagination using code in wordpress.
this did far displays list.
$loop = new wp_query( array( 'post_type' => 'events' , 'posts_per_page' => 3) ); $count = $loop->post_count; if ( $loop->have_posts() ) : ?> <h2 style="position:relative;top:100px" align="center"> news & events</h2> <div id = "menu" style="position:relative;top:100px;left:350px"> <ul> <li class = "aa"><a class="anchor" id="all" href="#">all</a></li> <li class = "aa"><a class="anchor" id ="videos" href="#">videos</a></li> <li class = "aa"><a class="anchor" name = "links" id="links" href="#">links</a></li> <li class = "aa"><a class="anchor" id = "our events" name ="our events" href="#">our events</a></li> </ul> </div> <br> <br><br> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="pindex" style="position:relative;top:100px;left:-450px"> <?php if ( has_post_thumbnail() ) { ?> <div class="pimage"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a> </div> <?php } ?> <div class="ptitle"> <h2><?php echo get_the_title() ?></h2> <div style="width:20%;position:relative;top:10px;left:550px" ><?php echo the_content();?> </div> </div> </div> <?php endwhile; if ( $loop->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> previous', 'domain' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'next <span class="meta-nav">→</span>', 'domain' ) ); ?></div> </div> <?php endif; endif; wp_reset_postdata();
can me this?
you use method display custom post events
, pagination is
$args = array( 'post_type' => 'events', 'posts_per_page' => 3 ); $posts_array = get_posts( $args ); // print_r($posts_array); foreach ( $posts_array $post ){ echo $post->id; }
Comments
Post a Comment