Get single post from tags array

$args = array( ‘type’ => ‘post’, ‘orderby’ => ‘name’ ); $tags = get_tags($args); foreach($tags as $tag) { $the_query = new WP_Query( ‘tag=’.$tag->name ); if ( $the_query->have_posts() ) { $the_query->the_post(); $desired_posts[] = get_the_ID(); // all the post IDs stored here. } else { // no posts found } wp_reset_postdata(); } $args1 = array( ‘post_type’ => ‘post’, … Read more

Orderby my needs in foreach loop like by title or something?

Try below code to filter the data by title in Ascending Order: $meta = get_post_meta(get_the_ID(), ‘_custom-meta-box’, true ); $title_array = array(); foreach ($meta as $key11 => $value11) { if($meta[$key11] > 1) { $my_postid11 = $value11; $title = get_the_title($my_postid11); $id = $my_postid11; $title_array[$id] = $title; } } asort($title_array); foreach ($title_array as $key22 => $value22) { $my_postid22 … Read more

Styling text and images in the_content()

I think the problem is the way you use the foreach with HTML inside. I usually use this way, so try perhaps to modify your code like this : <?php if (have_posts()) { while (have_posts()) { the_post(); the_content(); // get_template_part( ‘template-parts/content’,’article’ ); $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ … Read more