define orderby URL with meta_key=post_views_count
define orderby URL with meta_key=post_views_count
define orderby URL with meta_key=post_views_count
List Posts For Terms Of A Custom Taxonomy For Any Post Type
Your array is a PHP construct and only meaningful to PHP, as far as MySQL is concerned it’s just a string of characters. If you need to query on that data it should be separated out into individual keys.
Use custom fields wp_query Ex <?php $args = array( ‘post_type’ => ‘page’, ‘meta_query’ => array( array( ‘key’ => ‘mytitle’, ‘value’ => ‘title’, ‘orderby’ => ‘mytitle’, ‘order’ => ‘DESC’ ), ) ); $query = new WP_Query( $args ); if ( have_posts() ) while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <tr> <td><?php echo the_field(‘educational_ranking’); ?></td> <td><a href=”https://wordpress.stackexchange.com/questions/60150/<?php … Read more
if you use the native wp_query to select posts instead of custom sql queries you can check against the have_posts() method of wp_query
&orderby=date will return posts by their dates. <?php query_posts(‘post_type=page&post_parent=2&posts_per_page=-1&orderby=date&order=ASC’); ?> Replace first line with this to show post according to their date. Reference – Passing variables to query_posts Update – To sort the posts as per custom field value, Here’s the new code. query_posts(‘post_type=post&posts_per_page=-1&orderby=meta_value&meta_key=next_open_day&order=ASC’); ?> Note – The date should be saved in – YYYY-MM-DD … Read more
You need to post the query code of both the post query and the gallery query; no one can really make a guess otherwise. You can try using <?php wp_reset_query(); ?> after the post query to force a reset. See http://codex.wordpress.org/Function_Reference/wp_reset_query
Figured it out myself, for anyone else that needs help here are the two options.. <!–Method 1–> <?php $query = new WP_Query(); $query->query(‘post_type=page&p=’ . of_get_option(‘slide_page1’));while ($query->have_posts()) : $query->the_post(); ?> <?php the_title(); ?> <?php endwhile; wp_reset_query(); ?> <!–Method 2–> <?php $slide1 = of_get_option(‘slide_page1’);?> <?php $loop = new WP_Query( array(‘p’ => $slide1, ‘post_type’ => array(‘post’, ‘page’), )); … Read more
query_posts Avoid this function at all costs. The likely cause of your problem is queries not cleaning up after eachother. Your call to query_posts will have modified the main query ( wasting the original ), and messed up everything following it. Instead use WP_Query followed by wp_reset_postdata $query = new WP_Query(‘cat=17&posts_per_page=1&meta_key=FeaturedOnHomepage&meta_value=yes’); if($query->have_posts()){ while ($query->have_posts()) { … Read more
Simple custom post query for all the posts or many of them not working