Get Custom Field Values
This plugin provides a powerful widget, shortcode (with shortcode builder tool), and template tags for easily retrieving and displaying custom field values for posts or pages. The power of custom fields gives this plugin the potential to be dozens of plugins all rolled into one. This plugin allows you to harness the power of custom fields/meta data. Use the “Get Custom Field” widget, the [custom_field] shortcode (which has a post editor sidebar widget to help you build the shortcode), or one of six template tags to retrieve and display custom fields. Find a custom field for the current post, a specified post, a recent post, or randomly. And for the custom field values found by the plugin, you may optionally specify text or HTML to appear before and after the results. If nothing is found, then nothing is display (unless you define text to appear when no results are found). If multiple results are found, only the first will be displayed unless you specify a string to be used to join the results together (such as “,”), in which case all will be returned. Visit the Examples section to see how this plugin can be cast in dozens of different ways. There are six template tags provided by this plugin. Here they are, with an explanation of when they are appropriate for use: c2c_get_custom() : Use this inside “the loop” to retrieve a custom field value for a post c2c_get_current_custom() : This is only available on the permalink post template (single.php) and page template (page.php). Can be used inside or outside “the loop”. Useful for using custom field to define text you want to include on a post or page’s header, footer, or sidebar. c2c_get_post_custom() : Useful when you know the ID of the post whose custom field value you want. c2c_get_random_custom() : Retrieve the value of a random instance of the specified custom field key, as long as the field is associated with a published posted, non-passworded post (you can modify a setting in the plugin file to search passworded posts as well). c2c_get_random_post_custom() : Retrieves the value of random custom field(s) from a post when you know the ID of the post you’re interested in. c2c_get_recent_custom() : Retrieves the most recent (according to the associated post’s publish date) value of the specified custom field. You can filter the custom field values that the plugin would display. Add filters for ‘the_meta‘ to filter custom field data (see the end of the code file for commented out samples you may wish to include). You can also add per-meta filters by hooking ‘the_meta_$sanitized_field‘. $sanitized_field is a clean version of the value of $field where everything but alphanumeric and underscore characters have been removed. So to filter the value of the “Related Posts” custom field, you would need to add a filter for ‘the_meta_RelatedPosts‘. Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage Developer Documentation Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the numerous template tags, hooks, and shortcode provided by the plugin. As an overview, these are the template tags provided the plugin: c2c_get_custom() : Template tag for use inside “the loop” and applies to the currently listed post. c2c_get_current_custom() : Template tag for use on permalink (aka single) page templates for posts and pages. c2c_get_post_custom() : Template tag for use when you know the ID of the post you’re interested in. c2c_get_random_custom() : Template tag for use to retrieve a random custom field value. c2c_get_random_post_custom() : Template tag for use to retrieve random custom field value(s) from a post when you know the ID of the post you’re interested in. c2c_get_recent_custom() : Template tag for use outside “the loop” and applies for custom fields regardless of post. These are the hooks provided by the plugin: c2c_get_custom_field_values_shortcode : Filter to customize the name of the plugin’s shortcode. c2c_get_custom_field_values_post_types : Filter to customize the post types that should support the shortcode builder metabox. get_custom_field_values/can_author_use_shortcodes : Filter to customize if post author can make use of the ‘custom_field’ shortcode. get_custom_field_values/show_metabox : Filter to customize if the shortcode builder metabox is shown. The shortcode provided is [custom-field], which has a number of attributes to customize its behavior and output.
Top keywords
- custom37×4.86%
- field25×3.29%
- post24×3.15%
- custom field21×2.76%
- c2c14×1.84%
- template13×1.71%
- shortcode11×1.45%
- value9×1.18%
- filter8×1.05%
- random8×1.05%
- custom field values7×0.92%
- field values7×0.92%
Image Widget
Image Widget is a simple plugin that uses the native WordPress media manager to add image widgets to your site. Image Widget Features Responsive MU Compatible Handles image resizing and alignment Link the image Add title and description Versatile – all fields are optional Upload, link to external image, or select an image from your media collection Customize the look & feel with filter hooks or theme overrides Quality You Can Trust Image Widget is developed and maintained by The Events Calendar, the same folks behind The Events Calendar, Event Tickets, and a full suite of premium plugins. This plugin is actively supported by our team and contributions from community members. If you see a question in the forum you can help with or have a great idea and want to code it up or submit a patch, that would be awesome! Not only will we shower you with praise and thanks, it’s also a good way to get to know us and lead into options for paid work if you freelance. Pull Requests & Translations Check us out on GitHub to pull request changes. Translations can be submitted here on WordPress.org. Documentation The built in template can be overridden by files within your template. Default vs. Custom Templates The Image Widget comes with a default template for the widget output. If you would like to alter the widget display code, create a new folder called “image-widget” in your template directory and copy over the “views/widget.php” file. Edit the new file to your hearts content. Please do not edit the one in the plugin folder as that will cause conflicts when you update the plugin to the latest release. New in 3.2: You may now also use the “sp_template_image-widget_widget.php” filter to override the default template behavior for .php template files. Eg: if you wanted widget.php to reside in a folder called my-custom-templates/ and wanted it to be called my-custom-name.php: add_filter('sp_template_image-widget_widget.php', 'my_template_filter'); function my_template_filter($template) { return get_template_directory() . '/my-custom-templates/my-custom-name.php'; } Filters There are a number of filters in the code that will allow you to override data as you see fit. The best way to learn what filters are available is always by simply searching the code for ‘apply_filters’. But all the same, here are a few of the more essential filters: widget_title This is actually a pretty typical filter in widgets and is applied to the widget title. widget_text Another very typical widget filter that is applied to the description body text. This filter also takes 2 additional arguments for $args and $instance so that you can learn more about the specific widget instance in the process of filtering the content. image_widget_image_attachment_id Filters the attachment id of the image. Accepts additional $args and $instance arguments. image_widget_image_url Filters the url of the image displayed in the widget. Accepts additional $args and $instance arguments. THIS IS DEPRECATED AND WILL EVENTUALLY BE DELETED image_widget_image_width Filters the display width of the image. Accepts additional $args and $instance arguments. image_widget_image_height Filters the display height of the image. Accepts additional $args and $instance arguments. image_widget_image_maxwidth Filters the inline max-width style of the image. Hint: override this to use this in responsive designs 🙂 Accepts additional $args and $instance arguments. Return null to remove this css from the image output (defaults to ‘100%’). image_widget_image_maxheight Filters the inline max-height style of the image. Accepts additional $args and $instance arguments. Return null to remove this css from the image output (defaults to null) image_widget_image_size Filters the selected image ‘size’ corresponding to WordPress registered sizes. If this is set to ‘tribe_image_widget_custom’ then the width and height are used instead. Accepts additional $args and $instance arguments. image_widget_image_align Filters the display alignment of the image. Accepts additional $args and $instance arguments. image_widget_image_alt Filters the alt text of the image. Accepts additional $args and $instance arguments. image_widget_image_link Filters the url that the image links to. Accepts additional $args and $instance arguments. image_widget_image_link_target Filters the link target of the image link. Accepts additional $args and $instance arguments. image_widget_image_attributes Filters a list of image attributes used in the image output. Similar to ‘wp_get_attachment_image_attributes’ Accepts $instance arguments image_widget_link_attributes Filters a list of attributes used in the image link. Similar to ‘wp_get_attachment_image_attributes’ Accepts $instance arguments Have You Supported the Image Widget? If so, then THANK YOU! Also, feel free to add this line to your wp-config.php file to prevent the image widget from displaying a message after upgrades. define( ‘I_HAVE_SUPPORTED_THE_IMAGE_WIDGET’, true ); For more info on the philosophy here, check out our blog post