Actually I have the problem that I provide a menu link (predefined in theme) to the latest post of a specific custom post type. I achieve this by the following function …
function get_latest_magazine_issue_url() {
global $wpdb;
$query = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type='magazine_issue' AND post_status='publish' ORDER BY post_date DESC LIMIT 1;";
$result = $wpdb->get_results($query);
if(is_object($result[0])) { return get_permalink($result[0]->ID); }
else { return ''; };
}
… fine til that point – but I recognized, that when I clicked on that link after adding a new cpt post, the link will still grab the post which was the latest when I implemented this link via widget. Is there any way to get around this without a flush_rewrite_rules() call? I wouldn't like to flush that way cause the codex says: http://codex.wordpress.org/Function_Reference/flush_rewrite_rules