yeah, the question is a bit unclear. but i think you need shortcode attributes
function get_custom_field_fn( $atts) {
global $post;
extract( shortcode_atts( array(
'meta' => ''
), $atts ) );
$custom_field_value = get_post_meta($post->ID, $meta, true);
return $custom_field_value;
}
add_shortcode('cf_name', 'get_custom_field_fn');
see the codex: http://codex.wordpress.org/Shortcode_API#Attributes
Related Posts:
- Problem with extract() with custom shortcode
- Pass Shortcode Attribute to footer Script
- Wp-query Order By problem
- Shortcode to insert default text and change one word throughout it?
- How To Show Shortcodes In WordPress Custom Fields?
- Shortcode to eliminate and replace with
- restrict access to specific urls on a specific period of time
- multible shortcodes (for differnt values) with one function
- Word Press – Dynamic Content [closed]
- How can I make a widget shortcode to control all the widgets?
- Custom shortcodes not inserting into visual composer columns
- How to filter $content in shortcode function
- Insert image in WordPress with HTML5 tag and caption function
- Custom Attachment Caption Fields
- how can I just add to parent theme function(s) instead of redeclaring whole the function
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Setting youtube size in functions.php
- Cannot save CPT meta box
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- Move Custom Fields on General Settings Page to New Location
- Display gallery on bottom after content
- Add button to kitchen sink toggle
- Skeleton Child Theme Add Icon Bar to Header Flex Grid
- Excerpts are not displayed by a shortcode on category pages
- Redirect to another page using contact form 7? [closed]
- WordPress Shortcode function display outside of widget
- check if the user is owner of current page
- shortcode help require
- Optimizing a WordPress site
- different style sheet for just one page template
- Help With Creating Shortcode
- Use html inside shortcode function
- Condition OR for current user ID
- How to retrieve the current post’s generated featured image size?
- Shotcode argument issues
- Shortcode parse error – wrong syntax
- Exclude category from shortcode
- wp_nonce_field is breaking form for reasons unknown
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Where do I store custom functions that call custom page template files?
- get_pages() Returns Only One Item
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- Why There Is No “get content by ID” Function
- Function shortcode – Set Parameter
- Adding an option to a shortcode
- Custom HTML markup
- How to use author meta in shortcode?
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Echoing function into WordPress NextGen gallery
- Output loop to function return?
- How to echo the value of an array element using a function via a shortcode
- Create custom function for hero image
- Randomizing wp_tag_cloud() in child theme
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- login_headertitle is deprecated since version 5.2.0
- How to append classname to body tag if guest user
- Woocommerce checkout field
- Where do I go to edit this area? [closed]
- How to include any template using Shortcode fuction?
- Replace plugin function with a custom function?
- How can I pass a shortcode value to the head in wordpress functions.php
- Add attribute only to first image of every post via functions.php
- Native gallery custom html output
- Different favicon on different pages
- Need to convert image url to a Base_64 data url with wordpress function..
- The_content and Preg_replace in loaded Iframe [closed]
- dynamic site link for future migration in echo do_shortcode()
- How to create shortcode with html and php content?
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Shortcode question
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- Problem with images URL after filter applying
- two search forms on the same page
- Function to replace comment’s accented characters before posting
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- Insert a field with PREG_REPLACE – strange behaviour
- How to echo Widget Title in Custom Frontend-Template Box
- New checkbox in custom widget isn’t saving data
- Linking Javascript in functions.php file
- how to display a page before the home page
- loginout function customization
- Shortcode of a function
- Function to check if custom page is used by page?
- show all the posts thumbnails
- implementing a centralized content “show-do-not-show” toggle?
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- How to change a meta value (of a published post) after X days.?
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?