Make a loop to return x number of posts, but only if they have content or excerpt

Below is an example — tested and worked. The SQL query is: AND ({$wpdb->posts}.post_content != ” OR {$wpdb->posts}.post_excerpt != ”) And the example: <?php // This would be in functions.php or somewhere else where appropriate. function posts_where_require_content_or_excerpt( $where, $wp_query ) { global $wpdb; $where .= ” AND (” . ” {$wpdb->posts}.post_content != ”” . ” … Read more

Generating a perfect loop

That’s because you’re looping twice due to the while. Completely unecessary. foreach ($orders_ids as $details) { $order = wc_get_order($details->order_id); $fornavn = $order->get_billing_first_name(); $etternavn = $order->get_billing_last_name(); $deltakerkategori = $order->get_meta( ‘_billing_field_447’, true ); $deltakerradio = $order->get_meta( ‘_billing_field_538′, true ); echo ”.$fornavn.’ ‘.$etternavn.’ ‘.$deltakerkategori.”https://wordpress.stackexchange.com/”.$deltakerradio.'<br>’; } Additionally, if that doesn’t fix it due to…well, magic, try this patch: foreach( … Read more

Separate First Post Loop

Try like this which fill skip first post: $i = 0; while ( have_posts() ) : the_post(); if($i > 0) get_template_part( ‘template-parts/content-home’, get_post_type() ); else { // design your first post as you wish with HTML, CSS the_title(); the_permalink(); the_post_thumbnail(); the_content(); the_author(); the_date(); } $i++; endwhile;