Forums

[resolved] Help with PHP string concatenation (2 posts)

  1. adalberto.solito
    Member
    Posted 2 years ago #

    Hi. I don't know PHP very well and I want to optimize this PHP snippet. In this code I'm creating the $image variable, which stores the data of the custom field "Immagine Grande".
    What I want to optimize is the href attribute of the a element, which at the end repeats "get_post_meta..." . I would like to use string concatenation but I don't know how to use it in PHP. Thank you for your help.

    <?php $image = get_post_meta($post->ID, 'Immagine Grande', true); if($image != '') : ?>
    
    <a href="<?php bloginfo('template_directory'); ?>/images/products/<?php echo get_post_meta($post->ID, 'Immagine Grande', true); ?>" rel="lightbox">
    <img src="<?php bloginfo('template_directory'); ?>/images/icons/zoom_24.png" alt="<?php _e("Immagine del Prodotto", "mytextdomain"); ?>" />
    </a>
    
    <?php endif; ?>
  2. adalberto.solito
    Member
    Posted 2 years ago #

    No more problems. I fixed it by myself after half an hour of experimenting!

    :)

Topic Closed

This topic has been closed to new replies.

About this Topic