{"id":34189,"date":"2015-01-28T04:43:33","date_gmt":"2015-01-28T04:43:33","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/conditional-tags-shortcode\/"},"modified":"2020-05-26T16:38:59","modified_gmt":"2020-05-26T16:38:59","slug":"conditional-tags-shortcode","status":"publish","type":"plugin","link":"https:\/\/roh.wordpress.org\/plugins\/conditional-tags-shortcode\/","author":4801455,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"0.2","stable_tag":"trunk","tested":"5.4.19","requires":"3.1","requires_php":"","requires_plugins":"","header_name":"Conditional Tags Shortcode","header_author":"Hassan Derakhshandeh","header_description":"","assets_banners_color":"","last_updated":"2020-05-26 16:38:59","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":5,"author_block_rating":0,"active_installs":100,"downloads":8190,"num_ratings":2,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"2"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[4060,4061,2681,170,80],"plugin_category":[43],"plugin_contributors":[78384],"plugin_business_model":[],"class_list":["post-34189","plugin","type-plugin","status-publish","hentry","plugin_tags-conditional","plugin_tags-conditional-tags","plugin_tags-context","plugin_tags-page","plugin_tags-shortcode","plugin_category-customization","plugin_contributors-shazdeh","plugin_committers-shazdeh"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/conditional-tags-shortcode.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>With this shortcode you can take control of where the content is displayed.<\/p>\n\n<h4>Usage<\/h4>\n\n<p>You can use all the <a href=\"http:\/\/codex.wordpress.org\/Conditional_Tags\">conditional tags<\/a> WordPress provides. Checkout examples below.<\/p>\n\n<p>Show text only on the homepage:\n    [if is_front_page] The text [\/if]<\/p>\n\n<p>Show text only on the About page of the site:\n    [if is_page=\"about\"] The text [\/if]<\/p>\n\n<p>Show only on the category archive view:\n    [if is_category] The text [\/if]<\/p>\n\n<p>You can add \"not_\" before the conditional tag to reverse the logic, example:\nShow on all pages of the site except the homepage:\n    [if not_is_front_page] The text [\/if]<\/p>\n\n<h4>OR<\/h4>\n\n<p>Using multiple parameters, the content is displayed when either of the conditions are met (\"OR\" comparison), for example, show text on both category and tag archive pages:\n    [if is_category is_tag] The text [\/if]<\/p>\n\n<h4>AND<\/h4>\n\n<p>To set multiple conditions you can nest the shortcode, for example show text only on homepage AND if the user is logged in:\n    [if is_user_logged_in][if is_front_page] The text [\/if][\/if]<\/p>\n\n<p>Show a link to wordpress.org site, only on single post pages and only on mobile devices:\n    [if wp_is_mobile][if is_single] <a href=\"http:\/\/wordpress.org\/\">WordPress<\/a> [\/if][\/if]<\/p>\n\n<h4>has_term_{taxonomy}<\/h4>\n\n<p>You can use this to check if the current post in the loops belongs to a custom term in the desired taxonomy. See: https:\/\/codex.wordpress.org\/Function_Reference\/has_term<\/p>\n\n<p>Example, check if current post has the \"jazz\" term in the \"genre\" taxonomy:\n    [if has_term_genre=\"jazz\"] The text [\/if]<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>menu-item-visibility<\/code> directory to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Enjoy!<\/li>\n<\/ol>","raw_excerpt":"A shortcode to display content based on context.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/34189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=34189"}],"author":[{"embeddable":true,"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/shazdeh"}],"wp:attachment":[{"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=34189"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=34189"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=34189"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=34189"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=34189"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/roh.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=34189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}