• Resolved taghaboy

    (@taghaboy)


    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 ‘;’

    <?php
    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.

    Thread Starter taghaboy

    (@taghaboy)

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

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

    Thread Starter taghaboy

    (@taghaboy)

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

    <?php
    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.

    Thread Starter taghaboy

    (@taghaboy)

    i need some help please.

    Thread Starter taghaboy

    (@taghaboy)

    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:

    <?php
    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

    Thread Starter taghaboy

    (@taghaboy)

    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 ‘problem with : echo’ is closed to new replies.