I have this permalink structure
: /%year%/%monthnum%/%postname%/
What I want to is, output the link of a post in the back-end and let users input a postname, that will automatically lead to that post (if it exists, otherwise 404)...
So, I have this:
function transform_pseudo_anchor_wpse_101201($match) {
if (isset($match[1])) {
return '(link: <a href="http://example.com/'.sanitize_title_with_dashes($match[1]).'" title="'.$match[1].'">'.$match[1].'</a>)';
}
}
$content = preg_replace_callback(
'%\(link: ?(.*?) ?\)%',
'transform_pseudo_anchor_wpse_101201',
$content
);
echo $content;
Of course, this does not work... But how can I make it work? So I want the get the exact link if someone links to a post that exists... So after example.com, the year/monthnum and postname has to come...