Created
April 8, 2022 09:47
-
-
Save mennwebs/ea4f7db56d899857faefe48dcff5701a to your computer and use it in GitHub Desktop.
WP Shortcode to show Custom Field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Custom Field: demo_field | |
| // Shortcode: [show_field] | |
| function show_custom_field() { | |
| $meta = get_post_meta( get_the_ID(), 'demo_field', true ); | |
| return '<em>' . $meta . '</em>'; | |
| } | |
| add_shortcode('show_field', 'show_custom_field'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment