{"id":305,"date":"2013-05-22T03:43:52","date_gmt":"2013-05-22T03:43:52","guid":{"rendered":"http:\/\/pixert.com\/blog\/?p=305"},"modified":"2014-06-09T05:10:31","modified_gmt":"2014-06-09T05:10:31","slug":"wordpress-conditional-tag-to-check-specific-menu","status":"publish","type":"post","link":"https:\/\/pixert.com\/blog\/wordpress-conditional-tag-to-check-specific-menu\/","title":{"rendered":"WordPress: Conditional tag to check a specific menu"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"319\" data-permalink=\"https:\/\/pixert.com\/blog\/how-to-modify-get-comment-author-link-open-new-window\/wordpress-logo-notext-rgb\/\" data-orig-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?fit=250%2C250&amp;ssl=1\" data-orig-size=\"250,250\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"wordpress-logo-notext-rgb\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?fit=250%2C250&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?fit=250%2C250&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?resize=250%2C250\" alt=\"wordpress-logo-notext-rgb\" width=\"250\" height=\"250\" class=\"aligncenter size-full wp-image-319\" srcset=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?w=250&amp;ssl=1 250w, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?resize=150%2C150&amp;ssl=1 150w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><br \/>\nFollowing conditional tag usually use in this filter function, wp_nav_menu_items<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">if( $args-&gt;theme_location == 'primary' )<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">if( $args-&gt;theme_location == 'secondary' )<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">if( $args-&gt;theme_location == 'primary' )<\/pre>\n<p>For an example, I want to add search box to Primary Menu in WPZOOM theme name <a title=\"Videozoom\" href=\"http:\/\/www.wpzoom.com\/members\/go.php?r=978&amp;i=l28\">Videozoom<\/a>. Conditional tag above make sure the search only show in a specif menu (Primary)<br \/>\n1. Open functions.php<br \/>\n2. Add following code to functions<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\nadd_filter('wp_nav_menu_items','search_box_function', 10, 2);\r\nfunction search_box_function( $nav, $args ) {\r\nif( $args-&amp;gt;theme_location == 'primary' )\r\nreturn $nav.&quot;&lt;li class='menu-header-search'&gt;&lt;form role='search' action='&quot;.get_bloginfo('url').&quot;' id='searchform' method='get'&gt;&lt;input id=&quot;s&quot; type=&quot;text&quot; name=&quot;s&quot; placeholder=&quot;Search&quot; \/&gt;&lt;input id=&quot;searchsubmit&quot; type=&quot;submit&quot; value=&quot;Search&quot; \/&gt;&quot;;\r\n\r\nreturn $nav;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Following conditional tag usually use in this filter function, wp_nav_menu_items if( $args-&gt;theme_location == &#8216;primary&#8217; ) &nbsp; if( $args-&gt;theme_location == &#8216;secondary&#8217; ) &nbsp; if( $args-&gt;theme_location == &#8216;primary&#8217; ) For an example, I want to add search box to Primary Menu in WPZOOM theme name Videozoom. Conditional tag above make sure the search only show in a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[54,5],"tags":[55,123,6],"class_list":["post-305","post","type-post","status-publish","format-standard","hentry","category-code-snippet","category-wordpress","tag-code-snippet-2","tag-conditional-tag","tag-wordpress-2"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1pvi1-4V","jetpack-related-posts":[{"id":292,"url":"https:\/\/pixert.com\/blog\/wordpress-conditional-tag-for-login-page\/","url_meta":{"origin":305,"position":0},"title":"WordPress Conditional Tag for Login Page","author":"Pixel Insert \/ Pixert","date":"March 6, 2013","format":false,"excerpt":"WordPress have conditional tags. The Conditional Tags can be used in your Template files to change what content is displayed and how that content is displayed on a particular page depending on what conditions that page matches Following conditional tag is specific to Login Page, that is currently not available\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"wordpress-logo-notext-rgb","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":257,"url":"https:\/\/pixert.com\/blog\/conditional-tags-for-wp-e-commerce\/","url_meta":{"origin":305,"position":1},"title":"Conditional Tags for WP E-Commerce","author":"Pixel Insert \/ Pixert","date":"August 29, 2012","format":false,"excerpt":"The following conditional works when you install WP E-Commerce and you want to add PHP code in page.php .I want to breadcrumbs in pages but doesn't want it to display on WP E-Commerce Product page, because the product already showing its own breadcrumbs The following conditional tag apple to non-Product\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo-300x68.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":222,"url":"https:\/\/pixert.com\/blog\/wpzoom-featured-category-widget-videozoom\/","url_meta":{"origin":305,"position":2},"title":"WPZoom Featured Category Widget with video for Videozoom theme","author":"Pixel Insert \/ Pixert","date":"April 6, 2012","format":false,"excerpt":"I made the following widget code to show Featured Category with Video embed code. The following widget works with Videozoom theme from WPZoom Open wpzoom-widgets.php in the functions folder of Videozom. \u00a0Add the following code at the bottom of the wpzoom-widgets.php [php] \/*---------------------------------------------*\/ \/* WPZOOM: Featured Category widget with Video\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":256,"url":"https:\/\/pixert.com\/blog\/exclude-featured-posts-from-wpzoom-featured-category-widget\/","url_meta":{"origin":305,"position":3},"title":"Exclude Featured Posts from WPZOOM: Featured Category Widget","author":"Pixel Insert \/ Pixert","date":"August 25, 2012","format":false,"excerpt":"Zenko WPZOOM Demo Site (see the documentation) I made customization to the widget to exclude Same Posts already been shown on Featured Slider to avoid duplication 1. Open featured-category.php in wp-content\/themes\/zenko\/functions\/theme\/widgets folder 2. Replace all code in featured-category.php with the following [code] <?php \/*------------------------------------------*\/ \/* WPZOOM: Featured Category widget *\/\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/08\/zenkofeapostswidget.jpg?fit=580%2C459&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/08\/zenkofeapostswidget.jpg?fit=580%2C459&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/08\/zenkofeapostswidget.jpg?fit=580%2C459&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":284,"url":"https:\/\/pixert.com\/blog\/how-to-add-show-thumbnail-option-in-wpzoom-featured-category-widget\/","url_meta":{"origin":305,"position":4},"title":"How to add &#8216;Show Thumbnail&#8217; option in WPZOOM Featured Category Widget","author":"Pixel Insert \/ Pixert","date":"February 18, 2013","format":false,"excerpt":"Tribune is a lovely magazine theme from WPZOOM. The theme has custom widgets name WPZOOM Featured Category Widget You could use this widget to display categories on homepage like the demo site\u00a0(Politics - World - Sports - Automotive). The widget show thumbnails by default, it doesn't have feature to disable\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"WPZOOMFeaturedCategory","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/02\/WPZOOMFeaturedCategory.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":229,"url":"https:\/\/pixert.com\/blog\/php-conditional-statement-to-identify-ipad-or-ipod-or-iphone\/","url_meta":{"origin":305,"position":5},"title":"PHP Conditional statements to identify iPad or iPod or iPhone","author":"Pixel Insert \/ Pixert","date":"June 1, 2012","format":false,"excerpt":"This tutorial will show you how to detect iPad or iPod or iPhone using PHP Devices which request content from your website (usually) pass a user agent string. This contains information such as its name, OS, browser version, and rendering engine. Apple\u2019s gadgets pass the following user agents, although you\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&ssl=1&resize=525%2C300 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/comments?post=305"}],"version-history":[{"count":0,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/305\/revisions"}],"wp:attachment":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/media?parent=305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/categories?post=305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/tags?post=305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}