从另一篇文章中提取短代码内容
我有一个短代码[Mark],它只用作文本的标记。另一个用于根据帖子ID提取标记内容的简码[MarkExt]。从另一篇文章中提取短代码内容
[Mark label="mrk"]Some text here[/Mark]
我需要做的是,当我调用
[MarkExt label="mrk" id=10]
是获得由[马克]在帖子ID指定的标签MRK包围的文本。 如何获得[标记]内容?
编辑:对不完整的帖子道歉。下面的代码的functions.php或插件文件什么我目前做的是
对于[标记]
function mark_shortcode($atts,$content = null){
return $content;
}
add_shortcode('Mark', 'mark_shortcode');
而对于[MarkExt]
function extract_shortcode($atts,$content = null){
$label = $atts['label'];
$pid = $atts['id'];
}
add_shortcode('MarkExt', 'extract_shortcode');
添加。
function mark_caption_shortcode($atts, $content = null) {
//$content is Some text here
return $content;
}
global $mark_content;
$mark_content = add_shortcode('mark', 'mark_caption_shortcode');
function extract_shortcode($atts,$content = null){
global $mark_content;
//here you will get content
$label = $atts['label'];
$pid = $atts['id'];
}
add_shortcode('MarkExt', 'extract_shortcode');
我可以从[标记]中获取内容,但是当我致电[MarkExt]时如何获取其内容? –
我对你的问题有疑问。我想,你需要马克短码的内容,对吗? –
yes.This确切。 –
你已经尝试过这么做了吗?请回顾[我如何问一个好问题](https://*.com/help/how-to-ask)。堆栈溢出不是一种编码服务。预计您会在发布之前研究您的问题,并尝试亲自编写代码***。如果您遇到* specific *,请使用[Minimal,Complete和Verifiable示例](https://*.com/help/mcve)中的相关代码更新您的问题,并对您尝试的内容进行总结。 – FluffyKitten