PHP code on Visual Composer Plugin

I want to add some php and html code in my page but i can’t do it using Visual Composer, i can choose the “Raw Html” Box but that doesn’t render PHP at all, only HTML.

Do you guys have any idea how can i do it?? Or is there a workaround solution?

1
1

So i found the answer with the help of Pieter Goosen and i would like to share it with you:

A good method will be to create a Shortcode.

To do it, just go to your template Functions.php file and create your function like this example:

function shortcode_hello( $atts ){
  $time = ( date('G') < 9 ) ? "good morning" : "good day";
    return "Hello, and " . $time . ', my name is Linda';
}
add_shortcode( 'hello', 'shortcode_hello' );

Now all you have to do is to place the [hello] shortcode on your page builder (Visual composer here).

Leave a Comment