Order query by post meta value

Take a look at the WordPress Codex: http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby function edit_posts_orderby($orderby_statement) { $orderby_statement = “meta_value DESC”; return $orderby_statement; } add_filter(‘posts_orderby’, ‘edit_posts_orderby’); If you’re making the WP_Query yourself you can change the orderby parameter to meta_value Take a look here: http://codex.wordpress.org/Class_Reference/WP_Query

Loop after page content

Updating a theme isn’t that hard. But it’s necessary to let it play nice with the current version of the core. Here’re some notes on what you might need to do: Query Templates Post Thumbnails & featured images The query Nowadays, we’re using get_posts() or new WP_Query for such cases, where you need to do … Read more

Setting get_queried_object

As per its laconic source: function get_queried_object() { global $wp_query; return $wp_query->get_queried_object(); } This function retrieves object from main query. As such it is affected by anything that changes main query. From your list that would be query_posts() (reason number umpteen it should not be used).

Show how many images are attached to a post/page on compose page

add_action( ‘add_meta_boxes’, ‘attached_images_meta’ ); function attached_images_meta() { $screens = array( ‘post’, ‘page’ ); //add more in here as you see fit foreach ($screens as $screen) { add_meta_box( ‘attached_images_meta_box’, //this is the id of the box ‘Attached Images’, //this is the title ‘attached_images_meta_box’, //the callback $screen, //the post type ‘side’ //the placement ); } } function … Read more

How to query a custom post type with a taxonomy filter but display post type archive page?

The simplest way is, in all honesty, to hook into wp_title and change things, and just be aware that the warnings are there but not showing in production (because you’ve property configured your server). What follows is a kind of hacky solution. If you take a look at get_queried_object… <?php function get_queried_object() { global $wp_query; … Read more

WordPress Loop: List All Posts by a Category & Subcategory

The cat and category_name parameters for WP_Query display “posts that have this category (and any children of that category)”. There are also examples of doing this in the Codex. $query = new WP_Query( ‘cat=4’ ); // or $query = new WP_Query( ‘category_name=staff’ ); I am not 100% sure what you mean by “I need all … Read more

Make one query for adding entries to database

Is there a $wpdb method available that will allow me to create the query, by looping through my query, and then execute it once I’m out of that loop? If you and your loop can construct the proper SQL, then use $wpdb->query. You can run any query you want with that, so whatever version of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)