ASC and DESC separately from orderby

I would do something like this: <script type=”text/javascript”> //http://www.netlobo.com/url_query_string_javascript.html function gup( name, default_value ) { name = name.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”); var regexS = “[\\?&]”+name+”=([^&#]*)”; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return default_value; else return results[1]; } //here you can output default values for sortby and … Read more

Order posts by date

Three loops http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters $time = time(); foreach ( range( 0, 2 ) as $yesterday ): // get relative time offset by $yesterday days $rel_time = strtotime( “-$yesterday days”, $time ); // get the digits $year = date( ‘Y’, $rel_time ); $day = date( ‘d’, $rel_time ); $month = date( ‘m’, $rel_time ); // get the … Read more

Ascending order has strange effects on wordpress loop

It seems the problem is solved by adding ‘posts_per_page’ => -1 which forces WordPress to show all posts matching the parameters. Here’s my final code: array ( ‘post_type’ => ‘symposia_program’, ‘days’ => $progDay, ‘meta_key’ => ‘class_number’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1 );

Ordering by ‘Title’ OR ‘Custom Field’

i assume its exclusive to either sort by title $_GET[‘sort_title’] OR sort by custom field ( but not necessarily) and you that you pass $_GET[‘sort_price’]. if neither are present, “title” is default. with that in mind, check both values if( isset($_GET[‘sort_title’]) ) { $sort_by = $_GET[‘sort_title’]; //orderby can accept multiple values } elseif ( isset($_GET[‘sort_price’]) … Read more

Adjust the order for returned posts

In order to accomplish what you desire, you’ll have to fetch the posts ahead of time. There is no way to specify in SQL an arbitrary ordering given an ID list. query_posts() creates another main query, throwing out the main query. Since you’re doing this anyway, you can use get_posts() to return a list of … Read more

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