post_content; $n=0; $miss=[]; foreach($map as $file=>$id){ $url=get_permalink($id); // href="anterior/FILE.htm" (puede tener mayúsculas y espacios delante) $pat='#href="anterior/'.preg_quote($file,'#').'\.htm"#i'; $c2=preg_replace($pat,'href="'.$url.'"',$c,1,$cnt); if($cnt>0){ $c=$c2; $n++; } else $miss[]=$file; } wp_update_post(["ID"=>17990,"post_content"=>$c]); echo "repuntados=$n/23\n"; if($miss) echo "NO ENCONTRADOS: ".implode(", ",$miss)."\n"; // verificar que no quedan anterior/*.htm $rest=preg_match_all('#anterior/[\w-]+\.htm#i',get_post(17990)->post_content,$mm); echo "enlaces anterior/*.htm restantes: $rest\n"; if($rest) foreach($mm[0] as $x) echo " $x\n";