Help creating functions & shortcodes
-
Hi!
Thank you in advance for checking out my post.
I am wondering if anyone can help me with creating a function and shortcode.
I set up a custom field in my posts called smurl.
This is what I would like to display in my loop.
<div class="smurl_div"><input type="text" class="smurl_box" value="<?php $key="smurl"; echo get_post_meta($post->ID, $key, true); ?>"></div>
However, I would like it to only display if the field has a value.
If it is null, I would not like it to display.
At present, if it is null, the div and input still displays (obviously).I would also like to be able to have code for the functions.php of my theme so that I can place the value of smurl in the loop using:
<?php get_smurl();?>
and a shortcode[smurl] for within postsAnd so I can place the code
<div class="smurl_div"><input type="text" class="smurl_box" value="<?php $key="smurl"; echo get_post_meta($post->ID, $key, true); ?>"></div>
in the loop using:
<?php get_smurl_div();?>
and a shortcode[smurl_box] for within postsIs this possible? I am still learning so any help is greatly appreciated.
Thank you.
- The topic ‘Help creating functions & shortcodes’ is closed to new replies.