Custom Fields
Tuesday, August 7th, 2007 | Sites
I’m discovering WordPress’s Custom Fields. They are absolutely fabulous to build filmography pages! Once the hard work but then one has a template that can be used over and over again!! However, I’m really not good at coding php strings.
Does anybody know what I need to add to the following code to get it to return the words without the link (Official site) if there is no value?
<a href=”<?php echo get_post_meta($post->ID, “Photo Gallery”, $single = true); ?>”>Photo Gallery</a><br />Â
The following gives me an error. [edit:] I figured it out in case someone is interested:
<?php
$values = get_post_meta($post->ID, “Photo Gallery”, $single = false);
if ( is_array($values) ) { ?>
 <a href=”<?php echo $values[0]; ?>”>Photo Gallery</a>
<?php } else { ?>
 <?php echo ‘Photo Gallery’; ?>
<?php } ?><br />
No comments yet.
Leave a comment
Radio.Blog
Archive
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006