Last active
April 13, 2019 08:39
-
-
Save webhasan/9105526 to your computer and use it in GitHub Desktop.
wp: query post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(is_front_page()){ | |
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1; | |
}else{ | |
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; | |
} | |
$the_query = new WP_Query(array( | |
'post_type' => 'slider', | |
'category_name=>staff', | |
'posts_per_page' => get_option( 'posts_per_page' ), | |
'paged' => $paged | |
)); | |
if ( $the_query->have_posts() ) : | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
?> | |
<h1><a href="<?php the_permalink();?>"><?php the_title();?></a></h1> | |
<?php if(has_post_thumbnail()): ?> | |
<a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail('post-image'); ?></a> | |
<?php endif; ?> | |
<?php endwhile;?> | |
<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div> | |
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div> | |
<?php endif; | |
wp_reset_postdata(); ?> | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment