Post order by custom fields
That would be something like: query_posts( array( ‘cat’ => ’16’, ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘time’, ) ); See WP_Query documentation in Codex for more information.
That would be something like: query_posts( array( ‘cat’ => ’16’, ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘time’, ) ); See WP_Query documentation in Codex for more information.
Assign your custom queries to something other than $wp_query, that’s the variable that holds the default query for the page and you’re overwriting it with the image slider query.
Given your posted query and that you seem to still be trying to figure it out: First, off you should not use $wp_query = new WP_Query ();, since $wp_query is a global wordpress core object. Use any other variable to store the custom query in, $the_query = new WP_Query (); for instance. That being said, … Read more
yup it is fast, it would be even better for you to use the WP Transients API to cache your query for a short period. Basically: if($saved = get_site_transient(‘SOME_SORT_OF_ID’)){ echo $saved; } else { ob_start(); switch_to_blog(x); // x being the blog id your want to switch to // Do your quering and echoing here restore_current_blog(); … Read more
$query = new WP_Query( $args ); while( $query->have_posts() ) { // this fills in the $post global with the next post from the query $query->the_post(); // we’re now ina classic wordpress loop, and can use all the usual stuff the_title(); the_content(); echo $post->post_content; } // lets clean up after ourself so else we might mess … Read more
Since the sidebar was being deployed while inside the loop, the if ( have_posts() ) : was what was causing it to break. Here’s the fix: <div id=”FL-pest-libray-sidebar”> <?php $category_query_string = new WP_Query(array( ‘post_type’ => ‘page’ , ‘posts_per_page’ => ‘-1’ , ‘post_parent’ => ‘413’)); while ( $category_query_string->have_posts() ) : $category_query_string->the_post(); ?> <div <?php $catspacetitle = … Read more
In your theme’s functions.php or in a plugin: function prattle_custom_text( $input ) { if( is_admin() && ‘Published’ == $input ) { return ‘Saved’; } return $input; } add_filter( ‘gettext’, ‘prattle_custom_text’ ); It’s a tid bit dirty, but it’ll do the job.
I noticed you have an extra quote after order in your args. That affecting it?
I ended up solving this with a little bit of code (in the form of a plugin): if(isset($_GET[‘state’]) OR isset($_GET[‘city’])) { $url = explode(“https://wordpress.stackexchange.com/”, $_SERVER[‘REQUEST_URI’]); $url = end($url); $_SERVER[‘REQUEST_URI’] = “https://wordpress.stackexchange.com/” . $url; } This code in essence removes the “/arizona/” or “/arizona/phoenix/” from the REQUEST_URI global variable and replaces it with “https://wordpress.stackexchange.com/”, which then … Read more
I recently did exactly the same, you’ll have to use custom query: $date = time()-86400; /* today */ $querystr = ” SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->posts.post_status=”publish” AND $wpdb->postmeta.meta_key = ‘event_date’ AND $wpdb->postmeta.meta_value > ” . $date . ” ORDER BY $wpdb->postmeta.meta_value ASC “; $pageposts = $wpdb->get_results($querystr, OBJECT); foreach ($pageposts … Read more