1

I have the following code which is pulling in a custom field named phone.

<?php echo get_post_meta( get_the_ID(), 'ecpt_phone', true ); ?>

I additionally however want to add a little icon to the left of it. So I realise I have to include the src link somewhere, have tried the below, but am having no joy. Sorry a bit new...

<?php
$value = get_post_meta( get_the_ID(), 'ecpt_phone', true );
if( $value == 'True' ) { echo '<img src="/wp-content/uploads/2013/02/image.png">'; echo get_post_meta( get_the_ID(), 'ecpt_phone', true ); ?>

Thanks so much in advance.

2 Answers 2

1

Try to invert ' and " in the string definition. Which leads to

"<img src='/wp-content/uploads/2013/02/image.png'>";
Sign up to request clarification or add additional context in comments.

1 Comment

did you try to isolate the ... echo "<img src='/wp-content/uploads/2013/02/image.png'>"; ... then to see if it is displayed ? Also check that the path is right... I don't see any reason for that behavior
0

Remove the first / from src then try..

echo '<img src="wp-content/uploads/2013/02/image.png">';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.