Get a specific size from wp_get_attachment_image_src

Thanks maverick, your solution works <?php $args = array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘numberposts’ => 15, // -1, show all ‘post_status’ => ‘any’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ ); $images = get_posts($args); if($images) { ?> <images> <?php foreach($images as $image) { ?> <image><![CDATA[<?php echo wp_get_attachment_image_src( $image->ID, ‘listing_gallery_2x’)[0]; ?>]]></image> <?php … Read more

ACF – Get unique values of array

Is correct to do this way? `<ul id=”filters” class=”clearfix”> <?php $taxonomy = ‘categoria_sistemas_sanitarios’; $terms = get_terms( $taxonomy ); $unique = array(); echo ‘<li><span class=”filter-‘. $title . ‘ active” data-filter=”‘; $li = ‘ ‘; foreach ( $terms as $term) { $li .= ‘.’ . $term->slug.’, ‘; } $li = rtrim($li, ‘, ‘); echo $li; echo ‘”>Todos … Read more

Advertisement in Loop Posts wordpress

Use WP_Query and then loop the results using break when you want to stop to put the ad. $args = [ ‘posts_per_page’ => 5 ]; $posts = new WP_Query($args); Then loop 2 <section class=”posts”> <?php $cont = 0; ?> <?php while( $posts->have_posts() ) : $posts->the_post(); $cont++; $id = get_the_ID(); //Show your post here if($cont >= … Read more

show loop id post , only first id can read

You are getting the option “blog-featured-post”, which apparently returns two posts. Then, for each of these posts, you are making a query. Only the second one is actually used, since your if ( $q->have_posts() ) is outside of the loop. This query only has one post, since you use the post ID with the post__in … Read more

Last post in loop when even

<?php if( have_posts() ) : ?> <?php $count = 0; ?> <?php while( have_posts() ) : the_post(); ?> <?php global $count; $col=”col-lg-6″; if($count%3 == 0) { $col=”col-lg-12″; } else { $col=”col-lg-6″; } $count++; ?> <article id=”post-<?php the_ID(); ?>” <?php post_class( $col ); ?>> […] […] […] </article> <?php endwhile; ?> <?php endif; ?>