[Plugin: PostMash Custom – custom post order] improvement to plugin
-
the initial view of the posts is in the wrong order the first time you use the plugin because there are no values in menu_order. A solution to this would be to order the posts by date as the first variable, then by menu_order. Once you save the menu_order will always be dominant. LIke so.
ORDER BY post_date DESC, menu_order ASC”
hope this helps.
here is the new if statement:
foreach($res as $r) { $psql .= " $sep post_type ='$r' "; $sep = "OR"; } $psql = "($psql)"; // use this if you just want posts //$psql = " post_type = 'post' "; $date = $_GET['m']; $mmonth = substr($date, -2); $yyear = substr($date, 0, 4); //get posts from database $query_post .= "SELECT * FROM $wpdb->posts "; if (isset($_GET['cat']) && $_GET['cat'] != '0') { $query_post .= "INNER JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->term_taxonomy.term_id = " . $_GET['cat'] ; $query_post .= " AND $psql"; } else { $query_post .= "WHERE $psql "; } if (isset($_GET['m']) && $_GET['m'] != '0') { $query_post .= " AND YEAR($wpdb->posts.post_date) = " . $yyear ." AND MONTH($wpdb->posts.post_date) = " . $mmonth ; } $query_post .= " AND post_status = 'publish'"; $query_post .= " ORDER BY post_date DESC, menu_order ASC" ;
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘[Plugin: PostMash Custom – custom post order] improvement to plugin’ is closed to new replies.