我有这个permalink structure
: /%year%/%monthnum%/%postname%/
我想要的是,在后端输出一篇帖子的链接,让用户输入一个帖子名,这将自动引导到该帖子(如果存在,否则404)。。。
所以,我有这个:
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;
当然,这不起作用。。。但是我怎样才能让它工作呢?所以我想得到确切的链接,如果有人链接到一个帖子,存在。。。举个例子吧。com,年份/月份和postname必须到来。。。