PHP Syntax Error (Please Solve)

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>

Please help me to arrange this!

TIA!

Hi @cabaisma

I don’t have any experience in Wordpress, but I think the solution is :

if( function_existes("newsHeaderLineTkr") ) 

or escape the '

if( function_existes(\'newsHeaderLineTkr\') ) 

You need to concatenate the strings. I have modified your original code and use a ternary operator, but you should be able to use it as an example of how to rewrite your $page_title assignment.

$page_title = '<div class="announcement_title">some text<i class="fas fa-rss"></i></div><div class="announcement">'.(function_exists('newsHeadLineTkr') ? headLinePost() : '').'</div>';
1 Like

yeah its working @AbdelliNasredine the error is remove but the out put is not showing,

thank you sir, but the output is not showing

@cabaisma in the code, you are using function_existes to check whether newsHeadLineTkr function exists your PHP script and if so your calling headLinePost().
The problem maybe is newsHeadLineTkr function does not exist in your PHP script .