{"id":19139,"date":"2014-01-23T13:01:29","date_gmt":"2014-01-23T05:01:29","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=19139"},"modified":"2025-04-04T01:41:48","modified_gmt":"2025-04-03T17:41:48","slug":"wordpress-conditional-widget","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/","title":{"rendered":"Tailor WordPress Widgets for Specific Pages"},"content":{"rendered":"<p><strong>Note:<\/strong> This post was first published on January 23, 2014.<\/p>\n<p>Using WordPress, you have the ability to enhance your site\u2019s sidebar with additional content through widgets. By default, WordPress offers widgets such as post categories, tag clouds, search functions, and calendars. Standard themes like <a href=\"https:\/\/wordpress.org\/\/themes\/twentyten\">TwentyTen<\/a> and <a href=\"https:\/\/wordpress.org\/\/themes\/twentytwelve\">TwentyTwelve<\/a> will display these widgets across all pages \u2013 including the homepage, individual posts, static pages, and archives.<\/p>\n<p>However, what if you want to <strong>display widgets only on a specific page<\/strong>? Let\u2019s explore how this can be achieved.<\/p>\n<h2>Different Sidebar File<\/h2>\n<p>Every WordPress theme requires a <strong>sidebar.php<\/strong> file to house widgets, utilizing the <code>get_sidebar()<\/code> template tag to showcase these widgets on different pages.<\/p>\n<p>Imagine you have a <strong>Contact<\/strong> page and you wish the sidebar on this page to differ from those on other pages. In this case, you could create a new sidebar file named <strong>sidebar-contact.php<\/strong>.<\/p>\n<p>Then, within the <em>Contact<\/em> template file, you can introduce your new sidebar like this:<\/p>\n<pre>\r\nget_sidebar('contact');\r\n<\/pre>\n<p>Anything placed in the <strong>Contact sidebar<\/strong> will only show on the Contact page, allowing you to display widgets that are more pertinent to that specific page.<\/p>\n<h2>Using Conditional Tags<\/h2>\n<p>If you don\u2019t have a custom template for your page, another approach is to use <strong>conditional tags<\/strong>.<\/p>\n<p>Here\u2019s an example of how you can modify the <strong>page.php<\/strong> file. This code will display the Contact sidebar on the contact page, while other pages will show the standard sidebar:<\/p>\n<pre>\r\nif (is_page('contact')) {\r\n    get_sidebar('contact');\r\n} else {\r\n    get_sidebar();\r\n}\r\n<\/pre>\n<h2>Using Jetpack<\/h2>\n<p>Another method involves using the back-end admin area with Jetpack. Once you activate the <strong>Widget Visibility<\/strong> module in Jetpack, it enables you to <strong>hide or display<\/strong> widgets on specific pages.<\/p>\n<p>Navigate to <strong>Appearance &gt; Widgets<\/strong>. Here, you\u2019ll notice a new button labeled <span class=\"key\">Visibility<\/span> added to each widget. Click this button to adjust the visibility settings.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/wordpress-conditional-widget\/widget-visibility.jpg\" width=\"500\" height=\"301\"><\/figure>\n<p>For instance, I have configured a widget to appear only on the <strong>Contact<\/strong> page. Additionally, you can manage widget visibility based on Categories, Tags, and individual Posts.<\/p>\n<p>We hope you find this tip helpful. If you have any questions about this topic, please feel free to leave them in the comment box below.<\/p>","protected":false},"excerpt":{"rendered":"<p>Note: This post was first published on January 23, 2014. Using WordPress, you have the ability to enhance your site\u2019s sidebar with additional content through widgets. By default, WordPress offers widgets such as post categories, tag clouds, search functions, and calendars. Standard themes like TwentyTen and TwentyTwelve will display these widgets across all pages \u2013&hellip;<\/p>\n","protected":false},"author":113,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[49],"tags":[4663,252],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Tailor WordPress Widgets for Specific Pages - Hongkiat<\/title>\n<meta name=\"description\" content=\"Note: This post was first published on January 23, 2014. Using WordPress, you have the ability to enhance your site&#039;s sidebar with additional content\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tailor WordPress Widgets for Specific Pages\" \/>\n<meta property=\"og:description\" content=\"Note: This post was first published on January 23, 2014. Using WordPress, you have the ability to enhance your site&#039;s sidebar with additional content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2014-01-23T05:01:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-03T17:41:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/wordpress-conditional-widget\/widget-visibility.jpg\" \/>\n<meta name=\"author\" content=\"Thoriq Firdaus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@tfirdaus\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Thoriq Firdaus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/\"},\"author\":{\"name\":\"Thoriq Firdaus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\"},\"headline\":\"Tailor WordPress Widgets for Specific Pages\",\"datePublished\":\"2014-01-23T05:01:29+00:00\",\"dateModified\":\"2025-04-03T17:41:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/\"},\"wordCount\":348,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wordpress-conditional-widget\\\/widget-visibility.jpg\",\"keywords\":[\"ad-divi\",\"WordPress Tips\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/\",\"name\":\"Tailor WordPress Widgets for Specific Pages - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wordpress-conditional-widget\\\/widget-visibility.jpg\",\"datePublished\":\"2014-01-23T05:01:29+00:00\",\"dateModified\":\"2025-04-03T17:41:48+00:00\",\"description\":\"Note: This post was first published on January 23, 2014. Using WordPress, you have the ability to enhance your site's sidebar with additional content\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wordpress-conditional-widget\\\/widget-visibility.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wordpress-conditional-widget\\\/widget-visibility.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wordpress-conditional-widget\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tailor WordPress Widgets for Specific Pages\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\",\"name\":\"Thoriq Firdaus\",\"description\":\"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.\",\"sameAs\":[\"https:\\\/\\\/thoriq.com\",\"https:\\\/\\\/x.com\\\/tfirdaus\"],\"jobTitle\":\"Web Developer\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/thoriq\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Tailor WordPress Widgets for Specific Pages - Hongkiat","description":"Note: This post was first published on January 23, 2014. Using WordPress, you have the ability to enhance your site's sidebar with additional content","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/","og_locale":"en_US","og_type":"article","og_title":"Tailor WordPress Widgets for Specific Pages","og_description":"Note: This post was first published on January 23, 2014. Using WordPress, you have the ability to enhance your site's sidebar with additional content","og_url":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2014-01-23T05:01:29+00:00","article_modified_time":"2025-04-03T17:41:48+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/wordpress-conditional-widget\/widget-visibility.jpg","type":"","width":"","height":""}],"author":"Thoriq Firdaus","twitter_card":"summary_large_image","twitter_creator":"@tfirdaus","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Thoriq Firdaus","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/"},"author":{"name":"Thoriq Firdaus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807"},"headline":"Tailor WordPress Widgets for Specific Pages","datePublished":"2014-01-23T05:01:29+00:00","dateModified":"2025-04-03T17:41:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/"},"wordCount":348,"commentCount":6,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/wordpress-conditional-widget\/widget-visibility.jpg","keywords":["ad-divi","WordPress Tips"],"articleSection":["WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/","url":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/","name":"Tailor WordPress Widgets for Specific Pages - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/wordpress-conditional-widget\/widget-visibility.jpg","datePublished":"2014-01-23T05:01:29+00:00","dateModified":"2025-04-03T17:41:48+00:00","description":"Note: This post was first published on January 23, 2014. Using WordPress, you have the ability to enhance your site's sidebar with additional content","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/wordpress-conditional-widget\/widget-visibility.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/wordpress-conditional-widget\/widget-visibility.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/wordpress-conditional-widget\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Tailor WordPress Widgets for Specific Pages"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807","name":"Thoriq Firdaus","description":"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.","sameAs":["https:\/\/thoriq.com","https:\/\/x.com\/tfirdaus"],"jobTitle":"Web Developer","url":"https:\/\/www.hongkiat.com\/blog\/author\/thoriq\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-4YH","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/19139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=19139"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/19139\/revisions"}],"predecessor-version":[{"id":73654,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/19139\/revisions\/73654"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=19139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=19139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=19139"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=19139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}