/ Published in: PHP
Get the Value of the Custom Field Using the Shortcode
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function shortcode_field($atts){ 'post_id' => NULL, ), $atts)); $field = esc_attr($atts[0]); global $post; $post_id = 1*(NULL === $post_id) ? $post['ID'] : $post_id; } else { $post_id = 1*(NULL === $post_id) ? $post->ID : $post_id; } $answer = get_post_meta($post_id, $field, true); $answer = $answer; return $answer; } add_shortcode('field', 'shortcode_field');
URL: https://wpincode.com/kak-vypolnyat-shortkody-v-proizvolnyx-polyax-v-wordpress/#highlighter_338951