To get value of meta field use this magic shortcode:
[wpsm_custom_meta field="META-KEY-NAME" label="My label:" show_empty=1 posttext="after value text" icon="" list="" type="custom"]
Where can you use this shortcode? Well, it’s really powerful feature with unlimited possibilities. You can use it to show some featured attribute values in Product loops and on inner pages (use it inside Custom product areas). You can use it in Posts areas in Theme option – ads option to show some additional info for posts
You can even get meta values of Author of post (for example, can be useful if you want to show Phone or Contacts of Author of Post on Post page)
Let’s check parameters.
If you don’t need label – delete label parameter. Label is just test string which will be available before value.
The same as label, but this text will be visible after value.
Most important part. Must include name of custom or user field or attribute.
Add classes of icons (get them in RH Icon) in icon parameter. You can copy classes from each icon. Add also “rhicon” before as second class.
Example of code with these icons
[wpsm_custom_meta field="META-KEY-NAME" icon="rhicon rhi-bell"]
Icons will be visible before value. You can add also class mr5 or mr10 if you want to add some margin between value and icon.
[wpsm_custom_meta field="META-KEY-NAME" icon="fas fa-abacus mr5"]
For left margin, use ml5 or ml10
By Default, if your custom field doesn’t have value, shortcode does nothing and empty space will be returned. Set show_empty=1 if you want to show symbol “-” for empty values
By default, values will be visible as simple text. If you want to show it as bullet list, add list=1. You must also wrap whole code with ul tags. Example
[wpsm_custom_meta field="META-KEY-NAME" list=1]
[wpsm_custom_meta field="META-KEY-NAME-2" list=1]
This will get different type of data. By default, shortcode will grab custom field value.
type=author – it will get user meta field of post author.
type=vendor – it will get user meta field of vendor on vendor store pages
type=attribute will get woocommerce attribute value.
type=swatch will get woocommerce attribute value but it will be visible as swatch (color circles, custom images, etc). How to add swatches
type=attributelink will get attribute values and show them as links to attribute archive pages.
type=taxonomy will get taxonomy values.
type=taxonomylink will get taxonomy values and show them as links to taxonomy archives
Set labelblock=1 if you want to show Label on separate line
Set showtoggle=1 if you want to show Value as True/False. So, when your attribute has some value, it will be visible as Check Icon. If no value – it will be visible as Minus Icon
If your value is saved as array, you can use parameter subfield to get value from array. For example if you want to get first array value, use subfield=0.
The same as previous, but this is for cases when your value is stored as multidimensional array. So, syntaxis like
[wpsm_custom_meta field="custom_key" subfield=0 subsubfield="array_value"]
Is the same as php function
<?php $getvalue = get_post_meta($post->ID, "custom_key", true); echo $getvalue["array_value"];?>
add post id parameter if you want to get value from special post or product
You can specify limit of symbols in value. If your custom field has long text and you set symbollimit, text will be hidden by … if it has more symbols than symbol limit