posts)){ global $wpdb; $pid = get_query_var('p'); $permalink = html_entity_decode(get_permalink($pid)); if($permalink){ header ('HTTP/1.1 301 Moved Permanently'); header ('Location: '. $permalink); exit; } } } ?>