I have 2 shortcodes, [ref] and [references]. I need to get the content inside the [ref] shortcode and output it when the [references] shortcode is called.
For an example;
INPUT - This is some content in the webpage outside the shortcode. [ref] This is some content inside the shortcode "ref". [/ref] This is some other content. References : [references]
EXPECTED OUTPUT - This is some content in the webpage outside the shortcode. This is some other content. References : This is some content inside the shortcode "ref".
Here's the code that I've tried using, but I can't get it to display the content.
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');
I have no issue with the function for the "ref" shortcode, if there's some way I can get content inside it to the "references" shortcode that would be great!