Question

I am trying to assign the dynamic path of the image using php.

While trying to echo the path using

echo '<img src="'.$guild_image_path.'"/>';

I am getting the correct path.

But if i apply the same in my application i am not getting the image path.

Please refer my code below,

printf( '<span class="byline"><span class="rounded_image"><a  href="%4$s" rel="author"><?php echo '<img src="'.$guild_image_path.'"/>'; ?>%5$s</a></span></span>',  
                esc_url( get_permalink() ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
        get_the_author()
    );

Please help me to do this.

Was it helpful?

Solution 2

try debug using error_log or echo before printf() to make sure you are getting the value in the variable $guild_image_path.

error_log('image path'.$guild_image_path);

or

echo $guild_image_path;

OTHER TIPS

Why you use echo in printf? Second printf is arleady PHP so you dont need to open php tags again.

printf( '<span class="byline"><span class="rounded_image"><a  href="%4$s" rel="author"><img src="'.$guild_image_path.'"/>%5$s</a></span></span>',  
            esc_url( get_permalink() ),
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() ),
    esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    get_the_author()
);

Read more about printf: http://www.php.net/manual/ru/function.printf.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top