WordPress Development Asked by Ankit Sain on January 6, 2022
add_shortcode('sort_featured_restaurant','sort_featured');
function sort_featured(){
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
if(!$wp_query) {
global $wp_query;
}
$args = array(
'post_type' => 'food',
'orderby' => 'meta_value_num',
'meta_key' => 'listing_price',
'order' => 'DESC'
);
$query = new WP_Query( $args );
query_posts( array_merge( $args , $wp_query->query ) );
}
Use this code:
$args = array(
'post_type' => 'food',
'orderby' => 'meta_value_num',
'meta_key' => 'listing_price',
'order' => 'DESC',
'posts_per_page' => $count,
'paged' => $paged,
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ):
while ( $loop->have_posts() ) :
$loop->the_post();
echo get_the_title();
echo get_the_content();
endwhile;
endif;
Answered by Review Rights on January 6, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP