Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 01-11-2017, 12:44 AM   #1
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
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.
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 12:51 AM   #2
Paul&John
Confirmed User
 
Paul&John's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: YUROP
Posts: 8,497
try
Code:
$str .= '<div class="thumb-wrap"><a href="'.the_field('url').'">';
__________________
Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here
Paul&John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 12:59 AM   #3
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 24,767
Yeah - It's a quotes thing I'm sure - Need more coffee...
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 12:59 AM   #4
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
Quote:
Originally Posted by Paul&John View Post
try
Code:
$str .= '<div class="thumb-wrap"><a href="'.the_field('url').'">';
it's now giving me the blog posts url instead of the custom field's data

Thanks so much for the quick response.
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 01:05 AM   #5
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
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:
            $str .= '<div class="thumb-wrap"><a href="'.the_field('url').'">';
            if ( 
'gallery' == get_post_format$post->ID ) ) {
                
$str .= tn_moduleSingleSlider$post->ID$options['style'] );
            } elseif ( 
function_exists"has_post_thumbnail" ) && has_post_thumbnail$post->ID ) ) {
                
$featured_thumb tn_get_theme_option'tn_single_post_featured_image' );
                switch ( 
$featured_thumb ) {
                    case  
'full' :
                        
$str .= get_the_post_thumbnail$post->ID'native-image-thumb' );
                        break;
                    case 
'hide' :
                        
$str .= '';
                        break;
                    default:
                        
$str .= get_the_post_thumbnail$post->ID'blog_classic_thumb' );
                };
            }
            
$str .= '</a></div>';
        }; 
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 01:09 AM   #6
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 24,767
Quote:
Originally Posted by incredibleworkethic View Post
it's now giving me the blog posts url instead of the custom field's data

Thanks so much for the quick response.
url will just give the current page address - Try using myURL or something like that...
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 01:17 AM   #7
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
Quote:
Originally Posted by EddyTheDog View Post
url will just give the current page address - Try using myURL or something like that...
I'm using advanced custom fields, so they tell us to use the_field (calling the plugin's fields) and the field within the plugin called URL.

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?
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 01:17 AM   #8
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
Quote:
Originally Posted by Paul&John View Post
try
Code:
$str .= '<div class="thumb-wrap"><a href="'.the_field('url').'">';
So here's a visual of what happened:

incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 01:24 AM   #9
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 24,767
Quote:
Originally Posted by incredibleworkethic View Post
I'm using advanced custom fields, so they tell us to use the_field (calling the plugin's fields) and the field within the plugin called URL.

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?
Change URL in the custom field to myURL (or whatever) - Then use that...

Still only had 2 coffees so could be wrong.....
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 05:21 AM   #10
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
OK thanks I'll give it a try.
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 10:04 AM   #11
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
Tried, still giving the same result.

Interesting problem for sure.
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 10:12 AM   #12
redwhiteandblue
Bollocks
 
redwhiteandblue's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,774
Try echoing out the_field('url') to see what it produces. If it echoes out the url you want, the problem is elsewhere.
redwhiteandblue is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 10:40 AM   #13
Barry-xlovecam
It's 42
 
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
$url needs to be the location of a read of the data maybe. Then $data1 becomes the string or array of the data.
Barry-xlovecam is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 11:40 AM   #14
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
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.
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 11:46 AM   #15
Barry-xlovecam
It's 42
 
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
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
Barry-xlovecam is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 11:48 AM   #16
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,440
Quote:
Originally Posted by incredibleworkethic View Post
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.
I sent you a pm.

.
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 12:11 PM   #17
marlboroack
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: ☣
Posts: 9,327
skype me really quick I'll do it
marlboroack is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 12:14 PM   #18
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,440
Quote:
Originally Posted by marlboroack View Post
skype me really quick I'll do it
Yeah, like anyone would let you into their server.

Go away scammer.

.
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 12:26 PM   #19
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,141
+1 for Sarettah.

If you still need help, email me and I'll figure it out later tonight.
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 01:05 PM   #20
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
Quote:
Originally Posted by sarettah View Post
I sent you a pm.

.
Thanks to each and everyone for their help.

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!
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 01:19 PM   #21
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,440
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/

.
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 02:23 PM   #22
RyuLion
 
RyuLion's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: San Diego
Posts: 32,041
Quote:
Originally Posted by sarettah View Post
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/

.
Woot woot!!
__________________
RyuLion is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 02:52 PM   #23
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,232
Quote:
Originally Posted by sarettah View Post
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/

.
You are awesome!
__________________


Skype: CallTomNow

Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 03:48 PM   #24
blackmonsters
Yo Mamma!
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 19,879
Quote:
Originally Posted by sarettah View Post
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/

.

__________________
Camsoda pays :
Become a Cam Model or Sign up as a Webmaster
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 04:59 PM   #25
Struggle4Bucks
Sieg Hi!
 
Struggle4Bucks's Avatar
 
Industry Role:
Join Date: May 2011
Location: Lissabon
Posts: 3,613
When I read "php" I always get a headache...
Usually 2 weeks later another headache because of the invoice...

I'm out...
__________________
Half troll half amazing!
Struggle4Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 05:09 PM   #26
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
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!
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 07:41 PM   #27
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,440
Quote:
Originally Posted by Struggle4Bucks View Post
When I read "php" I always get a headache...
Usually 2 weeks later another headache because of the invoice...

I'm out...
I can get rid of that 2 week later headache for you.

I bill in advance ;p

.
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-11-2017, 07:42 PM   #28
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,440
Quote:
Originally Posted by incredibleworkethic View Post
Poo threads by currentlysober are great too!
GFY, your source for PHP and POO

.
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
$str, question, php, quick
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.