0

I am trying to echo html and php in a string but I get a syntax error with the code below.

                        $post_title .= '

                    <div id="show_neil" class="box five columns" data-target="#member_neil">'.
                    '<h4 class="name">'.

                    '<img src="' . get_bloginfo('template_directory') . '/img/team/neil.png">'.

                    .get_the_title($post_id).

                    '</h4>'.
                    '</div>

                    ';

How do I echo this?

6
  • 1
    First, missing semicolon (;) at the end of that (which shouldn't bother as long as there is nothing after that, but I suspect that there is more code after this). Second, what does bloginfo return? Third: what syntax error is it throwing? Commented May 20, 2015 at 15:54
  • bloginfo returns a url. at the end is suppose to be a '.' i've edited above... Commented May 20, 2015 at 15:55
  • i've updated post and added more code Commented May 20, 2015 at 15:58
  • Yes, the error is the dot (.) (after seeing your edit) after '/img/team/neil.png">'. Just remove it and you will be done. In a nutshell, replace '<img src="' . get_bloginfo('template_directory') . '/img/team/neil.png">'. with '<img src="' . get_bloginfo('template_directory') . '/img/team/neil.png">'. Besides, you should start to find different ways to concatenate strings. PHP offers tons of ways to concatenate elements and the one you're using is odd and hard to read and mantain. Commented May 20, 2015 at 15:59
  • 2
    @papirtiger: He should have posted the whole code at the very beginning, because there is a syntax error in the line he had posted, but we couldn't know what syntax error was until he posted the entire code. Apart from get_bloginfo and bloginfo, the syntax error was not thrown because of that. Commented May 20, 2015 at 16:01

1 Answer 1

2

Try to use get_bloginfo('template_directory') instead of bloginfo('template_directory').

Sign up to request clarification or add additional context in comments.

2 Comments

A good answer should contain an explanation why he should use get_bloginfo.
Sorry, I just updated my answer. Hope it is clear to you now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.