A group of tags inside a post ! [updated]

How to insert as a paragraph (by instance in a block-quote) a group of tags delivered by xili-tidy-tag-cloud ?

As you know, it is impossible to incorporate php inside a post content. But, for a webmaster, that don’t want to use the shortcode shipped since version 1.0, with « [shortcode] », it is easy :

1) add this specific function and the shortcode entry in your functions.php of your current theme :

/* xili-tidy-tags inside post as shortcode */
function xili_tidy_tags_inpost ($atts) {
	$arr_result = shortcode_atts(array('params'=>'', 'glue'=> ' - ' ), $atts);
	if (class_exists('xili_tidy_tags'))
		return implode($glue, xili_tidy_tag_cloud(html_entity_decode($params)."&largest=10&smallest=10&format=array"));
/* here some params are set by webmaster to help authors */	
		return '[xili-tidy-tags plugin inactivated]';
add_shortcode('xtt', 'xili_tidy_tags_inpost');

2) inside the content of the post add these lines for your shortcode adapted to your website and theme :

[xtt params="tagsgroup=trademark"]

3) see the result as here where we have choosen to display the list of tags grouping trademark terms in blockquote (but can be also inside a line of a paragraph).

apple | bbpress | imagemenu | leopard | tiger | wp

Instead glue as space between tags, we have defined a  » | « . As you can read in the php script, xili_tidy_tag_cloud() template tags works with the same rules and params (here largest…) as current wp_tag_cloud(). So it is possible with param format to return an array and implode it with glue. The result is therefore usable by shortcode tools.


As announced previously, the version 1.0 incorporate a generic shortcode named ‘xili-tidy-tags’ usable as here

[xili-tidy-tags params="tagsgroup=trademark&largest=10&smallest=10" glue=" | "]

In this cas, the group of tags named ‘trademark’ will be display inside a paragraph of a post. The params are defined as in `xili_tidy_tag_cloud()` and as in `wp_tag_cloud()`. The glue is chars inserted between the tags (if omitted default is a space).

To conclude : the shortcode from the plugin is very generic for webmaster. And the example, that webmaster can add in functions.php can be useful for authors of the website who have only to specify name of group and not style infos.

Don’ hesitate to comment below…

Ce contenu a été publié dans Experts corner, xili-tidy-tags, avec comme mot(s)-clé(s) , , . Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire