我有两个短代码,[参考]和[参考]。我需要获取[参考]短代码内的内容,并在调用[参考]短代码时将其输出。
例如:;
输入-这是网页中短代码之外的一些内容。[参考]这是短代码中的一些内容;请参阅;。这是一些其他内容。参考文献:[参考文献]
预期输出-这是网页中短代码之外的一些内容。这是一些其他内容。参考文献:这是shortcode中的一些内容;请参阅;。
这是我尝试使用的代码,但我无法让它显示内容。
function ref_shortcode( $atts , $content = null ){
ob_start();
static $i=1;
$return_value = \'<a href="https://localhost/reference-list/?page_id=12&preview=true#references"><sup>[\'.$i.\']</sup></a>\';
$i++;
return $return_value;
return ob_get_clean();
}
global $my_content;
$my_content = add_shortcode( \'ref\', \'ref_shortcode\' );
function references_shortcode( $atts , $content = null ){
ob_start();
global $my_content;
return \'<li>\' . $my_content . \'</li>\';
return ob_get_clean();
}
add_shortcode( \'references\' , \'references_shortcode\');
“我对”的函数没有异议;参考;shortcode,如果有什么方法可以将其中的内容;参考文件;这将是伟大的短代码!