<?php | |
/** | |
* Template Name: Featured | |
*/ | |
?> | |
<?php | |
$custom_query_args = array( | |
'post_type' => 'post', | |
'meta_key' => '_is_ns_featured_post', | |
'meta_value' => 'yes', | |
); | |
// Get current page and append to custom query parameters array | |
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; | |
$custom_query = new WP_Query( $custom_query_args ); ?> | |
<?php | |
// Pagination fix | |
global $wp_query; | |
$temp_query = $wp_query; | |
$wp_query = NULL; | |
$wp_query = $custom_query; | |
?> | |
<?php if ( $custom_query->have_posts() ) : ?> | |
<!-- the loop --> | |
<?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?> | |
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> | |
<?php the_excerpt(); ?> | |
<?php endwhile; ?> | |
<!-- end of the loop --> | |
<!-- pagination here --> | |
<?php | |
// Custom query loop pagination | |
previous_posts_link( 'Older Posts' ); | |
next_posts_link( 'Newer Posts', $custom_query->max_num_pages ); | |
?> | |
<?php else: ?> | |
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> | |
<?php endif; ?> | |
<?php | |
// Reset postdata | |
wp_reset_postdata(); | |
?> | |
<?php | |
// Reset main query object | |
$wp_query = NULL; | |
$wp_query = $temp_query; | |
?> |
This comment has been minimized.
This comment has been minimized.
For me the working solution for not showing featured posts was: `<?php foreach ($postslist as $post) : |
This comment has been minimized.
This comment has been minimized.
man how can i see the posts that are not featured with the upper code of featured.php |
This comment has been minimized.
This comment has been minimized.
Making one page template with two section Upper section show feat post section below show the non feat posts cant get it working [code]
'bedrijf',
'meta_key' => '_is_ns_featured_post',
'meta_value' => 'yes',
);
// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$custom_query = new WP_Query( $custom_query_args ); ?> Featuredhave_posts() ) : ?> have_posts() ) : $custom_query->the_post(); ?> max_num_pages ); ?>
'bedrijf',
'meta_key' => '_is_ns_featured_post',
'meta_value' => 'yes',
);
// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$custom_query = new WP_Query( $custom_query_args ); ?> Niet Featuredhave_posts() ) : ?> have_posts() ) : $custom_query->the_post(); ?> max_num_pages ); ?>?> [/code] now both shop feat posts any suggestions? |
This comment has been minimized.
This comment has been minimized.
I can show the featured posts by using |
This comment has been minimized.
This comment has been minimized.
@amitsarker89 Try changing the args so that |
This comment has been minimized.
This comment has been minimized.
how to show featured but per category? Not list all featured post, then just featured per post category? Suggestion of code pls? Tnx. |
This comment has been minimized.
If you want an example of how query everything except the featured post, here's how my team accomplished this: