mardi 27 janvier 2015

Do a summary based on sections in a post


I wonder if it's possible in wordpress to create a summary, let's say at the begining of the post, that displays links to all the post section ?


Example:



[summary title="Summary"]

[section]Title 1[/section]
Content

[section]Title 2[/section]
Content


would display :



Summary
- Title 1
- Title 2

Title 1
Content

Title 2
Content


What I tried is to define shortcodes [section] (that add a section to an array $sections for example) and [summary] (that iterate over $sections and display all titles). The problem is that I have access to all section items only at the end of the post (i.e. when all [section] have been parsed I suppose). If I put [summary] at the begining of the post, nothing appears.


Is there a way to order shortcode parsing ? or another way to implement this functionality ?


Thanks





Aucun commentaire:

Enregistrer un commentaire