Not solved yet, but this topic helped me with the permalink. Now its inside the html
https://www.ads-software.com/support/topic/95091?replies=5
I guess i need to use the custom fiel to the title too. But i read the “Using custom field” and didnt understand how to use it.
https://codex.www.ads-software.com/Using_Custom_Fields
Heres the code that worked with the permalink
<?php
$posts = get_posts('numberposts=10&offset=1');
foreach($posts as $post) :
setup_postdata($post);
?>
<?php if ( in_category(5) ) {
$link = get_post_custom_values('link');
$title_url = ($link) ? $link[0] : get_permalink();
echo '<a href="'.$title_url.'" ><b>'.$the_title.'</b></a>';
} else {
echo 'not category 5';
}
?>
<?php endforeach; ?>