Support » How-To and Troubleshooting » [Resolved] problem with : echo

[Resolved] problem with : echo

  • hi
    i have always problems with “echo”, this time i add the tag:
    <?php bloginfo(‘stylesheet_directory’); ?>/cat-banner/
    and the script dont work, error message :
    Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’

    foreach((get_the_category()) as $category) {
    echo '<?php bloginfo('stylesheet_directory'); ?>/cat-banner/' . $category->cat_name . '.jpg" alt="' . $category->cat_name . '" />';

    Thanks for help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You have incorrectly nested php tags. De-nest bloginfo. Oh, and don’t echo bloginfo.

    sorry, but i don’t understand you, can you pls provide an example.

    Nesting is one tag inside another: <?php <?php ?> ?>

    Thanks iridiax for reply,
    i try to do some change, but i’m really not a pro in php, but even if i try:

    foreach((get_the_category()) as $category) {
    echo 'bloginfo("stylesheet_directory");/cat-banner/' . $category->cat_name . '.jpg" alt="' . $category->cat_name . '" />';

    and steel not work, thanks for help.

    i need some help please.

    can you please to correct for me the PHP syntax, i’will be so happy if you do.

    You’ve probably figured this out by now, but since I came past this post when I was searching for the same thing, here’s what you could do.

    Rather than using bloginfo, use get_bloginfo. Then you can use something like:

    <?php echo 'Your Blog Tagline is: ' . get_bloginfo ( 'description' ); ?>

    I guess your code would then look like this:

    foreach((get_the_category()) as $category) {
    echo get_bloginfo ( 'stylesheet_directory' ) . '/cat-banner/' . $category->cat_name . '.jpg" alt="' . $category->cat_name . '" />';

    Note that stylesheet_directory is deprecated, so either use stylesheet_url to get to the main style.css, or template_directory if you want to get to the theme directory.

    More info under codex.wordpress.org/Template_Tags/get_bloginfo

    Hi karl19,
    Thanks a lot for your help, the code work perfectly.
    thanks again

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] problem with : echo’ is closed to new replies.
Skip to toolbar