Posted by & filed under WordPress.

Needed a way to display meta field info in a post as part of a site rebuild I’m working on.

The meta shortcode plugin adds a short code to WordPress that will display the contents of a meta field if it exists, and optionally something else if it doesn’t.

Download
You can get the plugin from the WordPress plugin library.

Usage
Use the [ metafield ] shortcode, without the spaces, where you want the info to appear.

The following attributes are available.

  • field – The name of the field to use. This is the only required attribute.
  • before – Text or HTML to display before the meta field. Defaults to nothing for single meta values or <ul> for cases where there are multiple values for a meta field.
  • after – Text or HTML to display after the meta field. Same defaults as before except it closes the list.
  • sorted – If there are multiple values for a meta key, setting this to true will sort them alphabetically. Setting to false or leaving blank will output in the order entered in WordPress. This attribute has no effect if the meta key only has a single value.
  • empty – Displayed when the meta key is empty or not found. Defaults to empty which means nothing will be displayed if the key isn’t found.

2 Responses to “Meta Shortcode plugin for WordPress”

  1. david

    Hi there,

    Good implementation for a plug-in.

    I cannot get the meta keys/values to return anything.
    I am using the name of the meta field like this [‘fieldname’] and [ fieldname ] like in your documentation but it’s not working. Am I missing something here?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *