How to orderby meta_value_num with dollar ($) sign

You could also use the posts_orderby filter: function wpse155827_posts_orderby_price( $orderby ) { return str_replace( ‘wp_postmeta.meta_value’, ‘substr(wp_postmeta.meta_value, 1)’, $orderby ); } add_filter( ‘posts_orderby’, ‘wpse155827_posts_orderby_price’ ); $theQuery = new WP_Query( array( ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘price’, ‘order’ => ‘ASC’, ‘suppress_filters’ => false, ) ); remove_filter( ‘posts_orderby’, ‘wpse155827_posts_orderby_price’ );

WP Query Exclude and Start by Menu Order Offset

You can use offset to number of post to displace or pass over. Like this. $args = array( ‘post_type’ => ‘my-post-type’, ‘posts_per_page’ => 3, ‘order_by’ => ‘menu_order’, ‘offset’ => ‘3’, ‘order’ => ‘ASC’ ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();

How to dynamically attach pictures to a carousel

It’s an interesting task. We can make a custom Slider Menu in Dashboard then featured images can be upload from there so that those images can be called dynamically in slider. First we have to make Theme Support and register Post Type in functions.php add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘slider’ ) ); add_image_size( ‘slider-image’, 1024, 550, … Read more

Splice together 2 WP_Query objects

I’m not sure I understand the question, but if you just wan’t do display something from resultset B on every nth iteration, you could use next_post() or simply call the_post() on the second query object. Of course you also need to check so there’s enough items left in the result and so on: $query1 = … Read more

Get category name from custom loop and echo it once

Here is an idea. Note, this will only work if all posts are in the desired category and if all posts have only category The posts are returned in an array which you can access through $currentissue->posts With this in mind, you can get the first post ID as follows $currentissue->posts[0]->ID Now, you can add … Read more

How to get to a specific position in wp_query?

I think instead of using PHP rand you’re better off limiting ( if you need to ) using posts_per_page and then getting a random set using orderby => ‘rand’. Full List of Ordering Parameters So if I were to edit your query it would look like this: $args = array( ‘post_type’ => ‘attachment’, ‘meta_key’ => … Read more

current_post not working – give me -1 for every post

What you are seeing is totally expected as you are trying to get the value of $current_post outside the loop. Before and after the loop, the value of $current_post will always be set to -1. To get the proper value, you need to check $current_post inside the loop, the first post will be 0 and … Read more

Accessing GET variable named ‘error’

Your problem is that you’re using Reserved Terms. error is a reserved term, you can’t use it. To get around this, you could intercept the request early, and do a redirect, changing the query parameters in the process. For example, handling a link get parameter: add_action( ‘wp’ , ‘reserved_term_intercept’ ); function reserved_term_intercept(){ global $wp_query; if( … Read more