Articles of wp query

Unable to get paginate_links working with a custom query

This question already has an answer here: How to fix pagination for custom loops? 4 answers

How to dynamically attach pictures to a carousel

I am trying to make single pages for each individual portfolio piece. I created custom posts & field types, but it only seems to allow one featured picture per post. Should I be adding my pictures in a different way? Or is there an option to add more featured images? Also, I am trying to […]

How to orderby meta_value_num with dollar ($) sign

The custom fields all have prices including $ signs, and a dot as separator. $theQuery = new WP_Query(array( ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘price’, ‘order’ => ASC )); All formatted like this: $24.95 $190.00 $1.40 They won’t sort correctly due to the dollar sign, is it possible to ignore or remove the first character / […]

Display posts with date wordpress default

I’m trying to display last posts with WordPress date, not date from server. <?php $week = date( ‘W’ ); $year = date( ‘Y’ ); $query = new WP_Query( ‘year=’ . $year . ‘&w=’ . $week ); while ( $query->have_posts() ) { $query->the_post(); // Page title the_title(); } // end while // Restore original Post Data […]

WP_Query times out

I have a form with 20 inputs that runs WP_Query and recieves results via ajax. For some reason: query gets considerably slower when 5+ inputs are filled It takes like 10 – 15s with 7 input values 15 – 25s with 8 input values and it increases in big chuncks with every next input I’ve […]

WP_Query loop within WP_Query loop

I’m trying to use a custom WP_Query loop within another one to display data from the inner loop independently from the main loop. I found this solution but don’t really understand how to use it. Here is the code, it works but the main loop generate duplicate posts. <?php // define the main query $main_args […]

Paginated pages are showing correct content but pagination links are not

I am using a custom WP_Query to display posts on static front page. and generating numbered pagination links with paginate_links functions. This is the code I have… $latest_args = array( ‘post_type’ => ‘post’, ‘category__not_in’ => array( 3 ), ‘ignore_sticky_posts’ => 1, ‘paged’ => $paged, ); $latest_query = new WP_Query( $latest_args ); if ( $latest_query->have_posts() ) […]

order by multiple meta keys in pre_get_posts

I want multiple orderby meta_query eg: orderby(‘_property_price’ => ‘DESC’,’_property_featured’ => ‘DESC’) This is what I am doing $query->set(‘meta_key’,array(‘_property_price’,’_property_featured’)); $query->set(‘orderby’,array(‘meta_value’=>’DESC’)); In SQL, it should be like ORDER BY _property_price, _property_featured DESC Any Solution to this ?

posts_per_page not working

For whatever reason the posts_per_page parameter isn’t working. I already called it earlier in the template and I used wp_reset_query(), yet it’s not working with the second instance. Any idea why? <div class=”new_home_single”> <ul> <?php $the_query = new WP_Query( ‘posts_per_page=6’ ); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <div class=”posting_classs”> <a […]

WP Rest API v2 return posts with specific tag

I am trying to get posts from blog: which are tagged “appcontent”. I tried this querry:[tag]=appcontent but it I still get unfiltered results. For example, this post: doesn’t have “appcontent” tag but it is still returned. “REST API – Filter Fields” plugin is installed. Could someone help me?