Display articles with a different template in the home page | Solved |

I haven’t tested this, but it looks like you just need to set an iteration variable (usually abbreviated $i), like this: <?php $i = 0; // This sets your variable $query = [ ‘post_type’ => ‘post’, ‘posts_per_page’ => 5 ]; $query = new WP_Query($query); while ($query->have_posts()) : { $query->the_post(); if($i == 0) : get_template_part(‘loops/acc-cards’); else() … Read more

Custom wp_query inside a conditional stament inside a template part doesn’t work: why?

You have assigned the queries result inside the first condition. So the values assigned to this variable “cm_offerta_post_figli” won’t be accessible inside the second elseif condition. Please put the below code on the top of First condition. It will work. <?php $cm_offerta_post_figli = new WP_Query( array( ‘post_type’ => ‘cm_offerta’, ‘post_parent’ => get_the_ID(), ‘order’ => ‘ASC’, … Read more

Trying to get all links in my posts

After further investigation, I noticed my theme was actually replacing all the anchor tags with shortcodes for SEO purposes, so there weren’t any links in the content anymore. I was able to make it work by replacing $content = get_the_content(); with $content = apply_filters( ‘the_content’, get_the_content() );

wordpress custom fields loop

I can just guess that there are numeric values inside recipe_star_rating post meta. Try this one if you have a numeric value, or just meta_value if there are string values. $args = array( ‘order’ => ‘DESC’, ‘meta_key’ => ‘recipe_star_rating’, ‘orderby’ => ‘meta_value_num’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : $counter … Read more

How to read taxonomy in loop?

I got it working here is the code: … <?php $term = get_term_by(‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ), get_queried_object()->term_id ); // $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $query = new WP_Query(array( ‘post_type’ => ‘recipe’, ‘meta_key’ => ‘recipe_star_rating’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, // ‘paged’ => $paged, … Read more