Support » Plugin: Global Content Blocks » content block with php variables included in html

  • Resolved vineela.s


    hi i have content block with shortcode [contentblock id=2];

    and the content in this global block is
    $themepath = “http://localhost/shriram/wp-content/themes/twentyeleven-child/images”;
    <div class=”bottomSlider”><img src=”$themepath/shriram-home-finel_39.jpg” /></div>

    i am printing my content block in template file like this

    <?php echo do_shortcode(‘[contentblock id=”2″]’);?>

    and the output is so strange below is the output

    $themepath = “http://localhost/shriram/wp-content/themes/twentyeleven-child/images”;
    <div class=”bottomSlider”><img src=”$themepath/shriram-home-finel_39.jpg” /></div>

    how can i use php variables in between html content and wht is the type of content i should select while creating content block?please help me on this…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author benz1


    You should use the PHP Code type, but be aware that the code will be interpreted by the PHP parser so should be written like this:

    $themepath = "http://localhost/shriram/wp-content/themes/twentyeleven-child/images";
    echo '<div class="bottomSlider"><img src="'.$themepath.'/shriram-home-finel_39.jpg" /></div>';

    or similar.

    Also, make sure you use the HTML tab of the editor when adding the code as the Visual tab will transform all tags into html safe entities which will raise an parser error if placed in a php content block.

    I have tried your solution

    $themepath = bloginfo(‘stylesheet_directory’);
    echo ‘<div class=”bottomSlider”><img src=”‘.$themepath.’/images/sliderImg.jpg” /></div>’;

    and the ouput is
    http://localhost/shriram/wp-content/themes/twentyeleven-child<div class=”bottomSlider”><img src=”/images/sliderImg.jpg”></div>

    themepath is printing above the div not inside image tag….

    help me on this .

    Plugin Author benz1


    You need to use the function ‘get_bloginfo’ instead of ‘bloginfo’ which directly echoes the result.

    I’m sorry but this is nothing to do with the plugin so I really can’t healp you any further with this.

    hi it is working like charm thank u so much for ur help 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘content block with php variables included in html’ is closed to new replies.