Quick PHP question
$str .= '<div class="thumb-wrap"><a href="<?php the_field('url'); ?>">';
I know I'm a newb, but this line breaks my code. Is there a way to call a field "URL" (advanced custom fields) within a string of PHP? If I hardcode the URL instead of that line of PHP, I can achieve what I want but I'm pulling it from a post because each url is pulled from a custom field. |
try
Code:
$str .= '<div class="thumb-wrap"><a href="'.the_field('url').'">'; |
Yeah - It's a quotes thing I'm sure - Need more coffee...
|
Quote:
Thanks so much for the quick response. |
This is me basically trying to link the featured image. Usually templates allow me to hardcode the featured image but this thing is deeply embedded.
PHP Code:
|
Quote:
|
Quote:
To simply my question, I've also added "url" as a custom field in the wordpress post. Any idea how to call on that within my original question? |
Quote:
http://image.prntscr.com/image/f6517...a48bc8aa52.png |
Quote:
Still only had 2 coffees so could be wrong:upsidedow..... |
OK thanks I'll give it a try:).
|
Tried, still giving the same result.
Interesting problem for sure. |
Try echoing out the_field('url') to see what it produces. If it echoes out the url you want, the problem is elsewhere.
|
$url needs to be the location of a read of the data maybe. Then $data1 becomes the string or array of the data.
|
Anyone want a few bucks to make this happen for me? I can't get it to work and I really like the theme lol.
|
PHP: file_get_contents - Manual
try this file() - Reads entire file into an array fgets() - Gets line from file pointer fread() - Binary-safe file read readfile() - Outputs a file file_put_contents() - Write a string to a file stream_get_contents() - Reads remainder of a stream into a string stream_context_create() - Creates a stream context $http_response_header |
Quote:
. |
skype me really quick I'll do it
|
Quote:
Go away scammer. . |
+1 for Sarettah.
If you still need help, email me and I'll figure it out later tonight. :upsidedow |
Quote:
Sarettah is more than kind and good karma should be hitting him often in his lifetime! He identified an error on my end, even though everyone's ideas were legit. Thanks again! :pimp:pimp:pimp |
Hey,
You r welcome but I should have been able to do that without having you send me the file. lol. I ran into something very similar a while back on something I was working on but forgot about it until I was looking at the file. For the record in case anyone searches on this at some point: The problem was that the wrong function was being used. the_field() echoes the value in the field to the page. get_field() pulls in the value. So the change was changing the_field() to get_field() and it all worked as expected. https://www.advancedcustomfields.com...ces/the_field/ . |
Quote:
|
Quote:
|
Quote:
:thumbsup:thumbsup |
When I read "php" I always get a headache...
Usually 2 weeks later another headache because of the invoice... I'm out... |
This is the best part of gfy. I've met some great people here. Keep your head out of the shit threads and you're good. Poo threads by currentlysober are great too!
|
Quote:
I bill in advance ;p . |
Quote:
. |
All times are GMT -7. The time now is 01:13 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc