从管理员后端wordpress 3.1链接页面

从管理员后端wordpress 3.1链接页面,wordpress,hyperlink,Wordpress,Hyperlink,我想在wordpress页面内进行链接,比如说,我的URL是www.test.com,我有www.test.com/p1 www.test.com/p2和www.test.com/p3页面,我想从管理端在p3中添加p1和p2链接。。现在,我只插入和p2相同的内容。。但是如果我的链接更改,我需要再次更改内容。。有什么解决办法吗。。因此,我可以只插入带有的页面ID,它将自动将其转换为链接。您可以使用快捷码api生成带有post ID的链接。 当您将以下代码添加到function.php中时 add_

我想在wordpress页面内进行链接,比如说,我的URL是www.test.com,我有www.test.com/p1 www.test.com/p2和www.test.com/p3页面,我想从管理端在p3中添加p1和p2链接。。现在,我只插入和p2相同的内容。。但是如果我的链接更改,我需要再次更改内容。。有什么解决办法吗。。因此,我可以只插入带有的页面ID,它将自动将其转换为链接。

您可以使用快捷码api生成带有post ID的链接。 当您将以下代码添加到function.php中时

add_shortcode('permalink', 'permlink_replace_func');

function permlink_replace_func($atts){

    extract(shortcode_atts(array(
        'id' => '',
        'lable' => 'link'
    ), $atts));

    $permpost = get_post($id);
    $html = '<a href="'.get_permalink($id).'" >';

    if ($lable==null) {
        $html .= $permpost->post_title;
    } else {
        $html .= $lable;
    }

    $html .= '</a>';

    return $html; 
 }
add_shortcode('permalink','permlink_replace_func');
函数permlink\u replace\u func($atts){
提取(短码)附件(数组)(
“id'=>”,
“标签”=>“链接”
)美元(附件);;
$permpost=get_post($id);
$html='';
返回$html;
}
您可以在帖子的内容区域中输入类似于
[permalink id=“8”lable=“hallo world”]
的字符串,以获得每个id指向另一篇帖子的链接

有关短代码的更多信息,请访问