add_filter('the_content', 'optimized_inline_related_articles_v4'); function optimized_inline_related_articles_v4($content) { if (!is_single() || !is_main_query()) return $content; global $post; $used_posts = array($post->ID); // 🔥 FIXED SPLIT (critical) $parts = preg_split('/(<\/p>)/i', $content, -1, PREG_SPLIT_DELIM_CAPTURE); $paragraphs = []; for ($i = 0; $i < count($parts) - 1; $i += 2) { $paragraphs[] = $parts[$i] . $parts[$i+1]; } $total_paragraphs = count($paragraphs); if ($total_paragraphs < 6) return $content; $ad_paragraphs = array(3,7,11,15); // ------------------------ // TAGS // ------------------------ $tags = wp_get_post_tags($post->ID); if (!$tags) return $content; $tag_ids = wp_list_pluck($tags, 'term_id'); $related_query = new WP_Query(array( 'tag__in' => $tag_ids, 'post__not_in' => $used_posts, 'posts_per_page' => 15, 'ignore_sticky_posts' => 1, )); $related_posts = array(); if ($related_query->have_posts()) { while ($related_query->have_posts()) { $related_query->the_post(); $post_tags = wp_get_post_tags(get_the_ID()); $shared_tags = count(array_intersect($tag_ids, wp_list_pluck($post_tags,'term_id'))); $related_posts[] = array( 'id' => get_the_ID(), 'title' => get_the_title(), 'link' => get_permalink(), 'shared_tags' => $shared_tags ); } wp_reset_postdata(); } if (empty($related_posts)) return $content; usort($related_posts, function($a,$b){ return $b['shared_tags'] - $a['shared_tags']; }); // ------------------------ // TOP INSERT // ------------------------ $top_positions = array(6,10,14); $count = 0; foreach($top_positions as $pos){ if(!isset($related_posts[$count])) break; if($pos >= $total_paragraphs) continue; if(in_array($pos,$ad_paragraphs)) continue; $rp = $related_posts[$count]; $inline_html = "
Read More: {$rp['title']}
"; $paragraphs[$pos] .= $inline_html; $count++; } // ------------------------ // BOTTOM INSERT // ------------------------ $bottom_positions = []; for($i=floor($total_paragraphs*0.4); $i<$total_paragraphs; $i++){ if(!in_array($i,$ad_paragraphs)) $bottom_positions[] = $i; } $max_bottom = min(3, count($related_posts)-$count); if($max_bottom > 0 && count($bottom_positions) > 0){ $interval = floor(count($bottom_positions)/$max_bottom); if($interval < 1) $interval = 1; for($b=0;$b<$max_bottom;$b++){ $pos_index = $b * $interval; if(!isset($bottom_positions[$pos_index])) break; $pos = $bottom_positions[$pos_index]; $rp = $related_posts[$count]; $inline_html = "
Read More: {$rp['title']}
"; $paragraphs[$pos] .= $inline_html; $count++; } } return implode('', $paragraphs); } IHC terms appointment of Ali Jahangir Siddiqui as new Ambassador to US as shameful
Follow
WhatsApp ✕

IHC terms appointment of Ali Jahangir Siddiqui as new Ambassador to US as shameful

IHC terms appointment of Ali Jahangir Siddiqui as new Ambassador to US as shameful

ISLAMABAD – Islamabad High Court (IHC) on Thursday has lashed out atgovernment over the appointment of the Ali Jahangir Siddiqui as newAmbassador in United States.

IHC termed the decision of appointing Ali Jahangir as Pakistani ambassadorto United States of America as shameful.

Hearing a case against Ali Jahangir, Justice Athar Minallah asked AttorneyGeneral about the appointment over which the AG said that the court’sreservations are right.

Ali Jahangir should have rejected the offer as the court is worried aboutthe image of Pakistan, said the judge.

Justice Athar further said that the interim government cannot decide overthis issue.

Subsequently, the hearing has been adjourned until October 4.