in my theme functions.php
i created a class contains some properties. my problem this when i use both string and functions in my property class show me the error say syntax error, unexpected '.', expecting ',' or ';'
for example i want when i print this property in my class show me the post title within <h1><a href=""></a></h1>
but when i use the the_title()
wordpress function within html tag string show me the above error. how i can use the the_title()
function until show me the title correctly?
class YPE_post_formats {
public $VP_icon = '<h1><a href="">'.the_title().'</a></h1>';
}
You cannot use functions in class property definition. Instead you could do it as follows:
Edit
I edited my answer removing the definition of
the_title()
as it is already defined in WordPress. Furthermore, I changedthe_title()
toget_the_title()
as this will not echo but get the contents of the title.