July 24, 201115 yr Hellllooo! On my word press I'm echo'ing out some stuff onto my page and basically, It will only echo that out if that page is a child of another page. Make sense? Hope it does as I'm new to PHP. <img src="<?php echo the_field('university_image'); ?>" alt="" style="float:left" /> BUT, when I echo this out, (or something similar, as I think I may have wrote the code above wrong), it decides to show the image perfectly in the page its echo'd out. But in the pages it is not supposed to be echo'd out, it puts a little 'X' in the top left corner as if the image was not to be found, or if it was moved. Any ideas? How would I make it so the field name 'university_image' would do what I want but will not display a little 'x' when not displayed, so ideally, not call for any image at all. Any help will be greatly appreciated!
July 24, 201115 yr Can you show me/us an example of what you aqtually mean? is it perhaps <?php echo '<img src="image source" />'; ?> What you mean to echo an image?
July 24, 201115 yr Author Right maybe this is a better of explaining: http://university-compare.com/university-guide/anglia-ruskin-university'>http://university-compare.com/university-guide/anglia-ruskin-university thats the link that is echoing the right image. BUT, that echo only works if its a child of a certain page, so it only displays when its needed. But where the 'img src' tag is written before the php, the 'img' tag appears in the website everywhere else. so on here: http://university-compare.com/ - there is a 'dead thumbnail' on every page, which is adding <br>'s and pusing the content down.. If that makes sense? I cant use echo '<img src="image source" />';?> because i've made it so the img src is just an upload to a media 'section', so it will call the field name/label, instead of the image source. Hope that helps my case?
July 24, 201115 yr Author Anything inside the php brackets would work, but not the way you said with a normal source.
July 24, 201115 yr what's your actual code for the page you linked that doesn't work? The resultant source is showing <img src="" alt="" style="float:left" /> so something's not quite right with the image field. Have you tried just echoing what is in that before the img src statement?
July 24, 201115 yr Author what's your actual code for the page you linked that doesn't work? The resultant source is showing <img src="" alt="" style="float:left" /> so something's not quite right with the image field. Have you tried just echoing what is in that before the img src statement? Those links do work? try em again.. REally don't do Wordpress much, but can't you just do something like: <img src="<?php echo get_post_meta($post->ID, "Thumbnail", true);?>" alt="custom image" /> Well I'm using at the moment: <img src="<?php echo the_field('university_image' );?>" alt="" /> But on this link it works fine: http://university-compare.com/university-guide/anglia-ruskin-university'>http://university-compare.com/university-guide/anglia-ruskin-university and on this link it shows a small error image gif(same as every other page): http://university-compare.com/ So I cant work out whats wrong, I think if there was a way to display the img src inside the PHP other than the way was said earlier then I wouldn't get that problem, because that php is ONLY echo'd out on that page. So that php anywhere else doesn't display, so that means there is <img src=" " alt="" /> floating about in the page when that certain page isn't being used, make sense? So thats why I'm getting that small gif image on the pages. Edited July 24, 201115 yr by OwenONeill
July 24, 201115 yr this might help http://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/ Edited July 24, 201115 yr by mteam
July 24, 201115 yr Author this might help http://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/ Checked that out, and doesn't help much with what I need, could help me in future so I bookmarked it, thank you though!
Create an account or sign in to comment