{"id":747,"date":"2025-03-24T14:27:34","date_gmt":"2025-03-24T14:27:34","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/gd-dynamic-content\/"},"modified":"2025-04-03T15:23:55","modified_gmt":"2025-04-03T14:23:55","slug":"gd-dynamic-content","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/core-widgets\/gd-dynamic-content\/","title":{"rendered":"GD > Dynamic Content"},"content":{"rendered":"\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-success mb-3\" role=\"alert\"><span class=\"fas fa-check-circle me-2\"><\/span><span class=\"flex-grow-1\">All Widgets come as Widgets, Shortcodes or Blocks. Learn more about our <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/core-widgets\/what-makes-geodirectory-widgets-special\/\">Super Duper Widgets<\/a>.<\/span><\/div>\n\n\n\n<p>The <strong>Dynamic Content<\/strong> widget can be used to <strong>output custom content dependent on a specific custom field value<\/strong>.<\/p>\n\n\n\n<p>This is a very powerful widget, its uses are almost limitless.&nbsp; <strong>See the examples section below.<\/strong><\/p>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-info mb-3\" role=\"alert\"><span class=\"fas fa-info-circle me-2\"><\/span><span class=\"flex-grow-1\">If your end goal is to output a <strong>button or badge<\/strong> to show a value, the <strong>GD > Post Badge<\/strong> widget might be a better fit.<\/span><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Widget Options<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Post ID<\/strong> &#8211; Leaving this blank will use the current post ID from the page or the loop, or you can specify and exact post ID if needed.<\/li>\n\n\n\n<li><strong>Field Key<\/strong> &#8211;\u00a0Selecting the custom field key to use as the conditional field.\u00a0 Standard field values are also available here such as post_date.<\/li>\n\n\n\n<li><strong>Field condition<\/strong> &#8211; This is the condition to use for the field value. You can match it to an exact value or simply use &#8220;is no empty&#8221; to show if a value is set. Many comparison types are available.<\/li>\n\n\n\n<li><strong>Value to match<\/strong> &#8211; If a comparison condition is used that requires a matching value then this is where you can enter a matching value.\u00a0<\/li>\n\n\n\n<li><strong>Text<\/strong> &#8211; This is the text that will be output <strong>only if the field conditions are met<\/strong>.\u00a0<em>Use %%input%% to use the input value of the field or %%post_url%% for the post URL, or the field key for any other info %%email%%.<\/em><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Example Output<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Example<\/h3>\n\n\n\n<p><strong>Output a screenshot of the listing website if it has been entered.<\/strong> <br>( <em>this can be done via the GD &gt; Post Images widget by default, this is just for example purposes here )<\/em><i style=\"font-weight: bold;\"><br><\/i><\/p>\n\n\n\n<p><i style=\"font-weight: bold;\">Widget input settings:<\/i><br>The output text will only show if the website custom field is not empty.<br><br>In the <strong>text<\/strong> input, the %%website%% variable will be replaced with the field value, which we then use the WordPress tool to generate an image URL for the website.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-IBrYkrIgsi.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><em><strong> Output result:<\/strong><\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-XnZAD8a7Zi.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Example<\/h3>\n\n\n\n<p><strong>Use a 3rd party shortcode with some dynamic content to show specific new content.<br><\/strong>Output specific WooCommerce products in a single page tab.<\/p>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-container mb-3 bg-image-fixed list-group list-group-flush list-group-numbered\">\n<div class=\"wp-block-blockstrap-blockstrap-widget-container mb-0 border-0 bg-image-fixed list-group-item\">\n<p>Create a custom field for the product IDs. Depending on your directory you might want to make this an admin edit only field.<br><figure><img loading=\"lazy\" decoding=\"async\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" srcset=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-9oFNWs4vIe.png 568w, https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-9oFNWs4vIe-300x102.png 300w\" width=\"568\" height=\"194\" class=\"attachment-large size-large\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-9oFNWs4vIe.png\" alt=\"\"><\/figure><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-container mb-0 border-0 bg-image-fixed list-group-item\">\n<p>Create a new shortcode tab and use the Dynamic Content shortcode to set the WooCommerce shortcode.\t<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-none\">&#091;gd_dynamic_content key=&quot;product_ids&quot; condition=&quot;is_not_empty&quot;&#093;\n&#091;products ids=&quot;%%product_ids%%&quot;&#093;\n&#091;\/gd_dynamic_content&#093;<\/code><\/pre>\n\n\n\n<p><figure><img loading=\"lazy\" decoding=\"async\" sizes=\"auto, (max-width: 566px) 100vw, 566px\" srcset=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-MvDqYZJ9OW.png 566w, https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-MvDqYZJ9OW-300x196.png 300w\" width=\"566\" height=\"369\" class=\"attachment-large size-large\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-MvDqYZJ9OW.png\" alt=\"\"><\/figure><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-container mb-0 border-0 bg-image-fixed list-group-item\">\n<p>Edit a listing and enter some WooCommerce product IDs, separated by a &#8221; , &#8221; comma if multiple. <br><figure><img loading=\"lazy\" decoding=\"async\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" srcset=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-BgVrqtN74i.png 466w, https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-BgVrqtN74i-300x55.png 300w\" width=\"466\" height=\"85\" class=\"attachment-large size-large\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-BgVrqtN74i.png\" alt=\"\"><\/figure><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-container mb-0 border-0 bg-image-fixed list-group-item\">\n<p>Visit the listing and you will see the entered products under the Products tab.<br><figure><img loading=\"lazy\" decoding=\"async\" sizes=\"auto, (max-width: 571px) 100vw, 571px\" srcset=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-eHwgCjAlJG.png 571w, https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-eHwgCjAlJG-300x179.png 300w\" width=\"571\" height=\"341\" class=\"attachment-large size-large\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-eHwgCjAlJG.png\" alt=\"\"><\/figure><\/p>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"featured\">Featured<\/h2>\n\n\n\n<p>Show Endorsement when the listing is &#8216;featured&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-none\">&#091;gd_dynamic_content key=&quot;featured&quot; condition=&quot;is_not_empty&quot;&#093;\n%%post_title%% has met and exceeded our strict qualifications in order to receive our endorsement.\n&#091;\/gd_dynamic_content&#093;<\/code><\/pre>\n\n\n\n<p>Show &#8216;Related Listings&#8221; (ads) when the listing is NOT &#8216;featured&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-none\">&#091;gd_dynamic_content key=&quot;featured&quot; condition=&quot;is_empty&quot;&#093;\n&#091;gd_listings hide_if_empty=&quot;1&quot; post_type=&quot;gd_place&quot; related_to=&quot;default_category&quot; post_limit=&quot;3&quot; sort_by=&quot;az&quot; title_tag=&quot;h3&quot; layout=&quot;3&quot; bottom_pagination=&quot;1&quot; mb=&quot;3&quot; slide_interval=&quot;5&quot;&#093;\n&#091;\/gd_dynamic_content&#093;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Dynamic Content widget can be used to output custom content dependent on a specific custom field value. This is a very powerful widget, its uses are almost limitless.&nbsp; See the examples section below. Widget Options Example Output Basic Example Output a screenshot of the listing website if it has been entered. ( this can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[213,422],"class_list":["post-747","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-extensions-features","gd_placecategory-core-widgets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=747"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/747\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=747"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=747"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}