{"id":19520,"date":"2011-06-15T23:53:46","date_gmt":"2011-06-15T18:23:46","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=19520"},"modified":"2020-04-24T14:49:37","modified_gmt":"2020-04-24T09:19:37","slug":"html-scripts-in-wordpress-category-descriptions","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2011\/06\/html-scripts-in-wordpress-category-descriptions\/","title":{"rendered":"How to Add HTML, Scripts in WordPress Category Descriptions"},"content":{"rendered":"<p>How can you add <strong>HTML code and scripts<\/strong> in <strong>WordPress category descriptions<\/strong>? WordPress category description is a text box which will by default strip any tags, scripts \u00a0or html code if you attempt to save it. But adding code for images, links, javascripts can enhance the usability, functionality and search engine rankings of your category pages.<\/p>\n<h3>Block WordPress Filters<\/h3>\n<p>Normally WordPress has powerful filters which block and strip code, so if you disable the filter, you can add whatever you like in the input forms. I followed this <a href=\"https:\/\/wordpress.org\/support\/topic\/category-description-strips-html-tags\/\" rel=\"noopener\">discussion<\/a> and found this useful tip.<\/p>\n<p>In the theme editor, open your themes <strong>functions.php<\/strong> file and add this code before the closing php closing tag <code>?&gt;<\/code><\/p>\n<pre><code>$filters = array('term_description' , 'category_description' , 'pre_term_description');\r\nforeach ( $filters as $filter ) {\r\nremove_filter($filter, 'wptexturize');\r\nremove_filter($filter, 'convert_chars');\r\nremove_filter($filter, 'wpautop');\r\nremove_filter($filter, 'wp_filter_kses');\r\nremove_filter($filter, 'strip_tags');\r\n}<\/code><\/pre>\n<p>Warning: Any wrong code entry to the functions.php file can take your blog down and block wp access. So fiddle with it only if you know what you are doing. If something goes wrong, edit the file to original via ftp, and all will be well.<\/p>\n<h3>Add Category Description Theme Support<\/h3>\n<p>Now you need to enable the category description code in your theme (which is usually absent). So in your theme editor open <strong>archive.php<\/strong> (which displays tags and categories archives) and add the following code after the Category \/ Tag headline.<\/p>\n<p><code>&lt;?php echo category_description(); ?&gt;<\/code><\/p>\n<h3>Add HTML to Category Description<\/h3>\n<p>Now you can add any <strong>html code and scripts <\/strong>to description fields of <strong>categories and tags<\/strong>.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-19523\" title=\"html-description\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/html-description.png\" border=\"1\" alt=\"Wordpress category html description\" width=\"487\" height=\"152\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/html-description.png 487w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/html-description-150x46.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/html-description-300x93.png 300w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><\/p>\n<p>Make useful category and tags descriptions and see the rising search engine ranking of these pages. Do you like this design + SEO tip?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How can you add HTML code and scripts in WordPress category descriptions? WordPress category description is a text box which&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[49,17],"class_list":["post-19520","post","type-post","status-publish","format-standard","hentry","category-blogging","tag-tutorials","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/19520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=19520"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/19520\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=19520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=19520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=19520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}