All Widgets come as Widgets, Shortcodes or Blocks. Learn more about our Super Duper Widgets.
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. See the examples section below.
If your end goal is to output a button or badge to show a value, the GD > Post Badge widget might be a better fit.
Widget Options
- Post ID – 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.
- Field Key – Selecting the custom field key to use as the conditional field. Standard field values are also available here such as post_date.
- Field condition – This is the condition to use for the field value. You can match it to an exact value or simply use “is no empty” to show if a value is set. Many comparison types are available.
- Value to match – If a comparison condition is used that requires a matching value then this is where you can enter a matching value.
- Text – This is the text that will be output only if the field conditions are met. 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%%.
Example Output
Basic Example
Output a screenshot of the listing website if it has been entered.
( this can be done via the GD > Post Images widget by default, this is just for example purposes here )
Widget input settings:
The output text will only show if the website custom field is not empty.
In the text 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.
Output result:
Advanced Example
Use a 3rd party shortcode with some dynamic content to show specific new content.
Output specific WooCommerce products in a single page tab.
- Create a custom field for the product IDs. Depending on your directory you might want to make this an admin edit only field.
- Create a new shortcode tab and use the Dynamic Content shortcode to set the WooCommerce shortcode.
<br>
- Edit a listing and enter some WooCommerce product IDs, separated by a ” , ” comma if multiple.
- Visit the listing and you will see the entered products under the Products tab.
Featured
Show Endorsement when the listing is ‘featured’.
Show ‘Related Listings” (ads) when the listing is NOT ‘featured’.