PHP code on Visual Composer Plugin

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