Sorting Attributes order when using get_the_terms

You will need to sort them yourself: $terms = get_the_terms( $post->ID, ‘category’); foreach ( $terms as $term ) { $newterms[$term->slug] = $term; } ksort($newterms); foreach ( $newterms as $term ) { echo “<li>” .$term->name. “</li>”; } Or, if you feel adventurous, the same with a filter: function alpha_sort_terms($terms) { remove_filter(‘get_the_terms’,’alpha_sort_terms’); foreach ( $terms as $term … Read more

Order posts by category name

I had the same struggle like you, thank i sat down and rethought the whole thing, what you actually need to is select all the categories, and pass the category id to it. Since you use a dlm_download you will need to do the following, get the terms from the dlm_download_category $cats = get_terms(‘dlm_download_category’); Loop … Read more

POSTS list in WordPress by views

Seems like you already have the custom field for views set up since that’s a phpMyAdmin screenshot. If so, you can use order_by=”post_views_count” in most wp_query based calls. For instance: $args = array( ‘post_type’ => ‘your_post_type’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘post_views_count’, ); $query = new WP_Query( $args ); //…and on with the loop <?php … Read more

Retrieve taxonomy terms in order of their post’s date?

I would use the terms_clauses filter, and then just use get_terms(): function wpse147412_order_terms_by_post_date( $pieces, $taxonomies, $args ) { global $wpdb; if ( ‘post_date’ !== $args[‘orderby’] ) { return $pieces; } $args = wp_parse_args( $args, array( ‘post_types’ => ‘post’ ) ); $pieces[‘fields’] = ‘DISTINCT ‘ . $pieces[‘fields’]; $pieces[‘join’] .= ” JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id … Read more

Order by the results of a function with WP_query

@JasCav Here is something to put you in the right direction. Maybe someone can edit where needed. // args $args = [ ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘posts_per_page’ => 8, ‘paged’ => get_query_var( ‘paged’ ), ‘meta_key’ => ‘team_school’, ‘meta_value’ => $school_type, ‘orderby’ => ‘wpse_last_word’, //<– make filter for ordering! ‘order’ => ‘ASC’ ]; // … Read more

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