Best Practices for a Completely Customizable Homepage – without plugins
Best Practices for a Completely Customizable Homepage – without plugins
Best Practices for a Completely Customizable Homepage – without plugins
WP Query sort by meta value
User Query sort on custom field then name
Try menu_order, like so: post_type=projects&order=ASC&orderby=menu_order&offset=1&posts_per_page=100 Vaguely related reference: http://codex.wordpress.org/Function_Reference/wp_list_pages#Parameters
You will find it prohibitively difficult to query on PHP serialized data, as it is essentially nonsense as far as MySQL is concerned. You should store price separately under its own key if you want to query on that data.
You have to add meta_key, orderby and order parameters to your query as described in the Codex: Order & Orderby Parameters: <?php $args = array( ‘post_type’ => ‘teacher’, ‘paged’ => $paged, ‘meta_key’ => ‘last_login’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’ ); $my_custom_query = new WP_Query($args); Also note I don’t use $wp_query variable to store the … Read more
Save the order in a Custom Field, then modify the main query to order on that custom field via pre_get_posts. Example for posts page: function wpa_custom_order( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘meta_key’, ‘your_order_key’ ); $query->set( ‘orderby’, ‘meta_value’ ); } } add_action( ‘pre_get_posts’, ‘wpa_custom_order’ );
I think this is not possible with the API functions provided by ACF. I would try to save the values to a temporary array first and then sort the values inside the array with php (using krsort() for example). Something like this (just to give an idea): while(has_sub_field(‘in_the_news’)) { $date = get_sub_field(‘published_date’); // $date = … Read more
EDIT From the comments from the OP There’s a few concerns though and suggestions on improvement. First of all, not sure if i missed something, but the list are not links? Second is that with this list it outputs a letter even though it doesn’t have a post assigned to the letter….. and Posts that … Read more
This code works! Sorts by category name (visible name), produces a list of links of categories (that aren’t empty) that are children of category_id. <?php //display sorted list of wpsc product categories $category_id = 10; $terms = get_terms(‘wpsc_product_category’,’hide_empty=1&parent=”.$category_id); usort($terms, function($a, $b) { return strcmp($a->name, $b->name); }); if ($terms) { foreach($terms as $term) { ?> <div> … Read more