I’ve got a question about a shortcode i want to make a automatic summary of multiple shortcodes eg:

[title_anchors] (this is a list of title_anchor 2 / 3)

[title_anchor id="2"]Test title 2[/title_anchor]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultrices 
lectus condimentum.

[title_anchor id="3"]Test title 3[/title_anchor]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultrices 
lectus condimentum.`

The title anchors need to get all the anchors in the text dynamically.

I’ve tried a regex on the content, but i’m stuck i don’t know how to go further with this.

Regex

function anchor_shortcode(){
$pattern = get_shortcode_regex();
preg_match_all("/$pattern/",$content,$matches);
$anchor_shortcode = array_keys($matches[2],'title_anchor');
}
add_action('wp', 'anchor_shortcode');

Read more here: Loop over shortcodes with a shortcode


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: