List most recently added posts (with a twist)
Try: $postslist = get_posts( ‘orderby=ID&numberposts=15′ ); Here, we’re ordering by the ID, which should relate to when the posts were added to the database.
Try: $postslist = get_posts( ‘orderby=ID&numberposts=15′ ); Here, we’re ordering by the ID, which should relate to when the posts were added to the database.
The default admin email can be found in woocommerce/templates/emails/admin-new-order.php the order items table is called in line 28, with a function called email_order_items_table. This function also takes an argument for including the thumbnail (see the class-wc-order.php, line 1052). if you copy the email templates to your theme folder, you can edit the admin-new-order.php file and … Read more
If you want to sort the custom post type ‘product’ by title, please try: array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘genre’, ‘field’ => ‘slug’, ‘terms’ => ‘ne’, ) ) ) where ‘field’ can in general be either ‘id’ or ‘slug’ (ref). You … Read more
Prepare the query before you loop over it: $first = array_shift( $the_query->posts ); $second = array_shift( $the_query->posts ); // now re-add in reverse order array_unshift( $the_query->posts, $first ); array_unshift( $the_query->posts, $second ); // this is now the first item while ($the_query -> have_posts()) : $the_query -> the_post(); // regular loop
So, from what I can tell, you want four columns of relatively equal length on a page, with a title letter every time you move on to a new letter of the alphabet. <?php $num_cols = 4; // set the number of columns here $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; // for pagination $args … Read more
I am guessing but based on your choice of placeholder names in the code above… $args = array( ‘meta_key’ => ‘myvalue’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ ); … your meta_key argument is wrong. That is the meta key not the meta value as your naming convention suggests. meta_key (string) – Custom field key. http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters … Read more
Have a look at the orderby parameters for WP_Query to see all of the valid values that can be. If wpcf-start-time is a meta key, then orderby should be meta_value, which will also require you set a meta_key argument to tell WP what meta key you want to order on- } elseif ($q->is_post_type_archive(‘cif-events’)) { $q->set(‘orderby’, … Read more
Instantiate in the strict sense is to create an instance of an object from a class. Plugins aren’t necessarily class-based, so I’m not entirely sure what you mean by instantiate. That said, WordPress includes the main plugin file for all active plugins on every front end and admin request. Whether this “instantiates” your plugin depends … Read more
You could use the filter term_links-post_tag to sort tags while ignoring their case: add_filter( “term_links-post_tag”, ‘themeslug_sort_tags_alphabetically’ ); function themeslug_sort_tags_alphabetically( $tags ){ natcasesort( $tags ); return $tags; } This code is to be placed in the functions.php of the child theme.
OK, so you want to define posts order by yourself. WP_Query allows you to do that – you’ll have to use orderby => post__in to achieve it. And that’s what you do. So why isn’t it working? Because of a typo 😉 Ordering posts by post__in preserves post ID order given in the ‘post__in’ array. … Read more