How do I allow users to sort posts? [duplicate]

This question already has an answer here: Closed 9 years ago. Possible Duplicate: How do I sort multiples pages? I want to allow users to sort a long list of posts (that are displayed on multiple pages) by custom fields. Here is my form… <form method=”post” id=”order”> <select name=”sort” onchange=”this.form.submit()”> <option value=””>Sort by</option> <option value=”zip”>Sort … Read more

Order posts by meta_value even if meta_key is not filled

I want to sort search results by the value of custom field (‘name-official’) for all posts (is this field filled or not). But when I add filter in function.php like function searchExcludePages($query) { if ($query->is_search) { $query->set(‘orderby’,’meta_value’); $query->set(‘meta_key’,’name-official’); $query->set(‘order’,’ASC’); } return $query; } add_filter(‘pre_get_posts’,’searchExcludePages’); i’ve received results with filled ‘name-official’ only. What should i do … Read more

WordPress: Sortable Metabox Fields Not Saving Position

I’ve run into a problem that has got me stumped: after upgrading to WP 3.6 my sortable metabox fields are not saving their position when you re-order them. Below is my code: PHP: function save_box( $post_id ) { $post_type = get_post_type(); // verify nonce if ( ! isset( $_POST[‘custom_meta_box_nonce_field’] ) ) return $post_id; if ( … Read more

How to sort terms with diacritical signs?

I have list of terms which happens to be the Polish Alphabet. Here’s how I list these terms: <ul> <?php $terms = get_terms(“taxonomy”, array(‘orderby’ => ‘title’, ‘hide_empty’ => 0)); foreach ( $terms as $term ) { echo “<li><a href=””. get_term_link( $term->slug, $term->taxonomy ) .””>” . $term->name . “</a></li>”; } ?> Everything works like a charm … Read more

blog posts sorting doesnt work while using get_query_var

I’m trying to show the latest posts using the get_query_var function. The function filters the posts according to their category. When I’m displaying the posts on the page they appear unsorted although I’ve added the $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘category__in’=>array( $cat), ‘order’ => ASC, ‘caller_get_posts’ => 1, ‘paged’=>$paged, ‘orderby’ => date, … Read more

Number of pages – multiple (custom) post types

My archive query contains a custom posts_per_page, order, orderby, post_type and paged (via wp-pageNavi). array ( ‘order’ => ‘DESC’, ‘orderby’ => ‘title’, ‘paged’ => 1, ‘post_type’ => Array ( ‘post’, ‘cust_article’, ), ‘posts_per_page’ => 15, ); My post_type contains ‘post’ and ‘cust_article’. I have 1 ‘post’ and 65 ‘cust_article’. posts_per_page is currently set to 5 … Read more

How to order users alphabetically by their last name?

I use the following shortcode and function to display members of some departments: add_shortcode( ‘list_of_members’, ‘members_listing’ ); /* usage: [list_of_members department=”psychology”] */ function members_listing( $department ) { $members = get_users( array( ‘meta_key’ => ‘department’, ‘meta_value’ => $department ) ); echo ‘<ul>’; foreach ( $members as $member ) { echo ‘<li>’ . $member->first_name . ‘ ‘ … Read more