Sort products without thumbnail in WooCommerce shop page

I would like to create a function that instead of hiding the products without thumbnails, would be ordered in such a way that the products with the highlighted image appear first on the shop page while those without the highlighted image appear at the end. I tried to modify an already existing function: function woocommerce_product_query( … Read more

Sort posts by newest child while keeping hierarchy intact

I have the following hierarchy within my wordpress posts (e.g.): -> Post 1 (pubdate: 2011-01-01) –> Post 5 (pubdate: 2011-01-02) —> Post 6 (pubdate: 2011-01-03) —-> Post 7 (pubdate: 2011-01-04) -> Post 2 (pubdate: 2011-03-01) –> Post 8 (pubdate: 2011-03-02) -> Post 3 (pubdate: 2011-02-01) –> Post 9 (pubdate: 2011-02-02) —> Post 10 (pubdate: 2011-02-03) … Read more

Sort by posts that have a featured image?

I’d like to sort posts on the index page to show those that have a featured image first. I’ve done this in functions.php: add_filter( ‘pre_get_posts’, ‘my_get_posts’ ); function my_get_posts( $query ) { if ( is_home() || is_archive() ) { $query->set(‘orderby’, ‘meta_value’); $query->set(‘meta_key’, ‘_wp_attached_file’); } } The causes no posts to be shown on the index … Read more

Custom-post-type-archive: posts sorted/filtered by year?

I have a custom-post-type wr_event whose posts are sorted by meta_key “event_date”. Therefore I have this handy function … function get_event_list( $latest = true, $order=”ASC” ) { echo ‘<ul class=”event-items”>’; $yesterday = time() – 24*60*60; $compare = $latest ? ‘>’ : ‘<‘; $args = array( ‘post_type’ => ‘wr_event’, ‘posts_per_page’ => -1, // show all posts … Read more