Last active
April 7, 2021 10:00
-
-
Save amorkovin/84ead01f8dce825b9a06d8d740b9a8f1 to your computer and use it in GitHub Desktop.
wp loop WP_Query kama thumbnail
This file contains 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 | |
$args = array( | |
'posts_per_page' => 5, | |
'cat' => "$rz_loan_card, $rz_loan_cash", | |
'meta_query' => array( | |
array( | |
'key' => '_rz_loan_fields|rz_loan_max_summ|0|0|value', | |
'value' => $summ, | |
'type'=> 'numeric', | |
'compare' => '>=', | |
), | |
array( | |
'key' => '_rz_loan_fields|rz_loan_time|0|0|value', | |
'value' => $days, | |
'type'=> 'numeric', | |
'compare' => '>=', | |
), | |
), | |
'meta_key' => 'post_views_count', | |
'orderby' => 'meta_value_num', | |
); | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
$args = [ | |
'posts_per_page' => -1, | |
'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1, | |
'cat' => $cat_diet_id, | |
'category__not_in' => array($cat_diet_id), | |
'paged' => $paged, | |
'meta_key' => 'slider', | |
'orderby' => 'meta_value_num', | |
'post__not_in' => array(123, 456), | |
'ignore_sticky_posts' => true, | |
]; | |
$meta_query_weight = array(); | |
if ($weight_ajax) { | |
$meta_query_weight['key'] = 'crb_weight'; | |
$meta_query_weight['value'] = $weight_ajax; | |
} | |
if ( count($meta_query_weight) ) { | |
$args['meta_query'] = array($meta_query_weight); | |
} | |
$loop = new WP_Query($args); | |
if ( $loop->have_posts() ) { | |
while ( $loop->have_posts() ) { $loop->the_post(); | |
$w = 660; $h = 300; | |
if ( kama_thumb_src() ) { | |
echo '<img src="'.kama_thumb_src('w='.$w.'&h='.$h).'" width="'.$w.'" height="'.$h.'" alt="'.get_the_title().'" />'; | |
} ?> | |
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a> | |
<?php | |
} | |
} | |
wp_reset_query(); | |
// wp_reset_postdata(); | |
// Set post type | |
switch ( $request->cat ) { | |
case 'credit-cards': | |
$args['post_type'] = 'credit-cards-post'; | |
break; | |
case 'loans': | |
$args['post_type'] = 'loans-post'; | |
break; | |
} | |
$args['meta_query'] = [ | |
[ | |
'key' => '_credit-cards-locale|credit-cards-locale-post-name|0|0|value', | |
'value' => sanitize_text_field( $request->searchText ), | |
'compare' => 'LIKE', | |
], | |
]; | |
$args['meta_key'] = 'post_views_count'; | |
$args['orderby'] = 'meta_value'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment