0

I am reading wp codex about outputing custom field value.

http://codex.wordpress.org/Function_Reference/get_post_custom

From that link, It shows how to output all custom fields associated with specific post

How can I take only specific custom fields value?

For example I added custom field name "SkypeID". In each post, skype ID can be anyone's skype ID

I want to be able to get the value of skype ID and output it on my function.php.

On my function, I want to be able to insert it so that I can produce a post/page and add skype call button that will invoke skype application and then call the user mentioned on the custom field.

Here is my skepe call button so far.

<div id="SkypeButton_Call_ValidSkypeID_1" style="margin:-32px 10em;">
<script type="text/javascript">
Skype.ui({
"name": "call",
"element": "SkypeButton_Call_ValidSkypeID_1",
"participants": ["ValidSkypeID"],
"imageSize": 32
});
</script>
</div>

this code works if I hard coded a valid skype ID in replacement to ValidSkypeID on line 1.

What I am trying to do now is to be able to insert skypeID on that location if there is a skype ID given in custom post.

Thanks

  • What is the custom fields name? – Remi May 7 '14 at 11:13
  • I believe OP mentioned that "SkypeID" is the custom field name. – codearachnid May 7 '14 at 11:16
0

I would suggest you could try something like this to insert the Skype id by using get_post_meta:

if (get_post_meta($post->ID, 'Skype_ID', true) == true) {
  echo get_post_meta( $post_id, "Skype_ID", true );
}
1

You are on the right track, but digging a little deeper into the codex you'll find methods for get_post_meta. So you could do something like this:

<?php $post_id = get_the_ID(); // or set this however you get the post id ?> 
<div id="SkypeButton_Call_<?php echo get_post_meta( $post_id, "SkypeID", true ); ?>_1" style="margin:-32px 10em;">
<script type="text/javascript">
Skype.ui({
"name": "call",
"element": "SkypeButton_Call_ValidSkypeID_1",
"participants": ["ValidSkypeID"],
"imageSize": 32
});
</script>
</div>
  • This helps me arrive on the solution as well. Tried to give upvotes but it seems im not yet allowed. Your answer is very well appreciated. Thanks – Charles Wayne May 7 '14 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.