Created
January 19, 2017 05:22
-
-
Save shubham9411/d2db11c680a64f04696cb4ecde28c2d6 to your computer and use it in GitHub Desktop.
How you can add custom fields to you WordPress Theme.
This file contains 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 | |
if(!function_exists('spx_custom_field')){ | |
function spx_custom_field($attr){ | |
global $post; | |
$name = $attr['name']; | |
if(empty($name)) return; | |
return get_post_meta( $post->ID, $name, true ); | |
} | |
} | |
add_shortcode('new_field','spx_custom_field'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment