PHP - Parse error, unexpected T_STRING

Ryan - Aug 18, 2015 at 12:54 PM
 Ryan - Aug 20, 2015 at 07:53 PM

I'm having a lot of trouble with my WordPress website and it seems to be because of this:

I want to display a custom field which is usually accomplished by inserting this simple code:

<?php echo get_post_meta(get_the_ID(), 'custom_field_name', TRUE); ?>

...but I get an error every time. Adding back slashes stops the error but nothing is displayed.

Any advice would be greatly appreciated.

Thank you!


1 response

Blocked Profile
Aug 18, 2015 at 05:51 PM
Hey there. I found this in the Wordpress man.

It looks like the TRUE could break it, if the syntax is csse sensitive. I do apologize for not knowing the wordpress syntax. I guess put that down on things to learn. Great more marketable skills!
I hope this helps!

Have FUN!

I have said it once, I will say it again. IT!
Thanks ac3mark. The link you sent has good info but doesn't help with this issue it appears. I've tried with tried with true lowercase and get the same error. It's something with the single ' mark. As soon as I add any code with single quotes in it, I get the error. I haven't encountered this before. The theme's PHP must be too advanced for me to modify. Oh well, I'll keep playing with it. Thanks again!
Blocked Profile
Aug 19, 2015 at 04:43 PM
Maybe try the ASCII code for the " ' " symbol?
Blocked Profile
Aug 19, 2015 at 06:55 PM
Ok, you will need to build the string quote, as in : '''

or 'Single quote''Single quote''Single quote'...Sometimes you need to emulate the string, like in ASP: Response.write("here is the string"""+"In Quotes"+"""."); The previous statement would output: here is the string "In Quotes". Give that a try!
Thanks for all of the advice buddy. Through hours and hours of trial and error, this finally worked:

'.get_post_meta($q->ID, 'price', true).'

This has been a wake up call that I need to get much stronger in PHP. Like you said, nothing wrong with more marketable skills.
Blocked Profile
Aug 20, 2015 at 05:15 PM
Atta boy! Way to Go! Should we mark it Solved?