Custom Fields and Shortcode together on Functions.php
-
Hello everyone, I was looking to do this, but because I could not find a solution, I decided to share in the forum for those who really know this. Here goes:
What I need to do is, when inserting a field of custom fields in a post, this complete a shortcode on the function.php to be called in the post that I want in the following way [hello].
Here are step example of the codes I use.
First create the shortcode with this code:
function mi_shortcode() { return 'Hello Manolo!'; } add_shortcode('hello', 'mi_shortcode'
And what i need is that adding a custom is called “manolo” this is completed within the short code.
So I tried the following code, but I have not worked:
add_shortcode('hola', 'myshortcode' function myshortcode() { return 'Hola <?php echo get_post_meta($post->ID, 'manolo', true); ?>!'; }
Could anyone help me? Did I explain well what I need?
Thanks in advance for any help you can give me!
Greetings!
- The topic ‘Custom Fields and Shortcode together on Functions.php’ is closed to new replies.