एक टैग क्लाउड प्रदर्शित करें - सीएसएस-ट्रिक्स

Anonim
 8, // font size for the least used tag 'largest' => 22, // font size for the most used tag 'unit' => 'px', // font sizing choice (pt, em, px, etc) 'number' => 45, // maximum number of tags to show 'format' => 'flat', // flat, list, or array. flat = spaces between; list = in li tags; array = does not echo results, returns array 'orderby' => 'name', // name = alphabetical by name; count = by popularity 'order' => 'ASC', // starting from A, or starting from highest count 'exclude' => 12, // ID's of tags to exclude, displays all except these 'include' => 13, // ID's of tags to include, displays none except these 'link' => 'view', // view = links to tag view; edit = link to edit tag 'taxonomy' => 'post_tag', // post_tag, link_category, category - create tag clouds of any of these things 'echo' => true // set to false to return an array, not echo it ) ); ?>

यदि इस फ़ंक्शन के लिए कोई भी आपूर्ति नहीं की गई है, तो डिफ़ॉल्ट आकार, "पीटी" जो थोड़ा असामान्य है और अक्सर अविश्वसनीय है, इसलिए सुनिश्चित करें कि आप उस पैरामीटर को बदलते हैं कि आप अपनी साइट पर सामान्य रूप से फोंट कैसे आकार देते हैं।

कम अजीब फ़ॉन्ट आकार

टैग क्लाउड प्रत्येक टैग में इनलाइन स्टाइल लागू करके अपने विविध फ़ॉन्ट आकारों को पूरा करते हैं। परिणामी फ़ॉन्ट आकार वास्तव में शैली की तरह अजीब हो सकता है = 'फ़ॉन्ट-आकार: 29.3947354754px;'। माइक समर्स इस प्रस्ताव का प्रस्ताव:


    8, // font size for the least used tag 'largest' => 40, // font size for the most used tag 'unit' => 'px', // font sizing choice (pt, em, px, etc) 'number' => 200, // maximum number of tags to show 'format' => 'array', // flat, list, or array. flat = spaces between; list = in li tags; array = does not echo results, returns array 'separator' => '', // 'orderby' => 'name', // name = alphabetical by name; count = by popularity 'order' => 'RAND', // starting from A, or starting from highest count 'exclude' => '', // ID's of tags to exclude, displays all except these 'include' => '', // ID's of tags to include, displays none except these 'link' => 'view', // view = links to tag view; edit = link to edit tag 'taxonomy' => 'post_tag', // post_tag, link_category, category - create tag clouds of any of these things 'echo' => true // set to false to return an array, not echo it )); foreach ($arr as $value) ( $ptr1 = strpos($value,'font-size:'); $ptr2 = strpos($value,'px'); $px = round(substr($value,$ptr1+10,$ptr2-$ptr1-10)); $value = substr($value, 0, $ptr1+10) . $px . substr($value, $ptr2); $ptr1 = strpos($value, "class="); $value = substr($value, 0, $ptr1+7) . 'color-' . $px . ' ' . substr($value, $ptr1+7); echo '
  • ' . $value . '
  • '; ) ?>

परिणाम यह हो जाता है:

Tag Name

इस मामले में:

Tag Name

लिंक किए गए बोनस पर ध्यान दें कि लिंक में "रंग -29" का एक वर्ग नाम है जो अब पहले नहीं था। अब आपके पास उनके आकार के आधार पर टैग नामों को रंगीन करने के लिए एक हुक है।