WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this code:

            <?php $site= get_post_custom_values('projLink'); 
                if($site[0] != ""){

                <p><a href="<?=$site[0]?>">Visit the Site</a></p>

            <?php }else{ ?>
                <p><em>Live Link Unavailable</em></p>
            <?php } ?>

After clicking the link I get this adress in the browser http://domain.com/Array

So i don´t think the


is correct.

How can I make it work? Thanks

share|improve this question
Sure you don't want to use the get_post_meta() function in this case? – Geert Jan 6 '12 at 9:04
up vote 0 down vote accepted

Use var_dump($site[0]) to see the structure of the array. And once you know that, then you can properly reference an item in that array. (You could also do var_dump($site) to get a full picture of what's going on.)

share|improve this answer
sorry I don´t understand! you mean i replace <?=$site[0]?> with that code? – Ricardo Jan 6 '12 at 9:23
<?php var_dump($site); ?> This won't solve your problem, but will give all info necessary to solve the problem. ie. Once I see the info outputted by var_dump, I know exactly how to work with an array. – Velvet Blues Jan 6 '12 at 10:08
Ok! Now my link looks like this: domain.com/array(1) { [0]=> string(17) – Ricardo Jan 6 '12 at 11:05
Based on the above, your code should work. Perhaps you should consider get_post_meta() as Geert suggested, since you are only interested in one value anyway, and there is only one value returned. – Velvet Blues Jan 6 '12 at 12:33
ok ! thanks a lot for the help! Best regards – Ricardo Jan 6 '12 at 14:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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