1

I am working with a WordPress site. I used Fancy Text element of the Visual composer in a post. But I want to show this on Homepage. And for homepage, I already get the Homepage template which I have used. I made a custom section with post of this Fancy text. But Homepage is in PHP language. So, my VC_Column and VC_Rows codes are not working on the homepage.

I have tried using

< ?php echo do_shortcode(“ ”); ? >

But I'm noob. Unable to use this also. and only the code is visible on the homepage.

Please tell me how I can use Visual Composer on PHP so that I can edit my homepage template of the theme.

Thank you.

1 Answers1

0

WordPress shortcodes provide you extra functionality and allow you to embed content into pages. do_shortcode, which you can use to add shortcodes to any part of your site.

https://developer.wordpress.org/reference/functions/do_shortcode/

The visual composer plugin feature can use with a short code within the page template.

<?php
  $content = 'test content';
  //number of vc_column you have a need to use, according to your requirement.
 echo do_shortcode( '[vc_row][vc_column width="1/1"]'.$content.'[/vc_column][/vc_row]' );
?>

You can try.

<?php

$array_ultimate_fancytext = array("fancytext_strings1" =>'[ultimate_fancytext strings_textspeed="35" strings_backspeed="0" fancytext_strings="Welcome Namaste Wellkumma Шъукъеблагъ iHola! Shagotom आईं ना Tusanyuse okubalaba" strings_font_size="desktop:60px;"]', 
"fancytext_strings2"=>'[cq_vc_cqbutton buttonlabel="Kidney Transplant" link="url:http%3A%2F%2Fwww.yourmedicament.com%2Fdoctors%2Fdr-abhay-kumar%2F|title:Dr.%20Abhay%20Kumar||"]');

foreach($array_ultimate_fancytext as $value){

    $content = do_shortcode($value);
    echo do_shortcode('[vc_row][vc_column]'.$content .'[/vc_column][/vc_row]' );

}
?>
Shivendra Singh
  • 2,986
  • 1
  • 11
  • 11
  • Thanks! Upvoted. I will try to implement this. I don't know whether this info will be useful me or not. Also I never implemented any shortcodes. – Ankit Kushwaha Jun 25 '19 at 05:16
  • visual composer plugin already implemented the shortcode you have need to call with do_shortcode any part of your site. just use above shortcode in your page template and see. – Shivendra Singh Jun 25 '19 at 06:20
  • I simply have to put this code in my theme php file? and I have to place my visual composer data in the place of "$content" ? I will try and reply you soon. Thank you. – Ankit Kushwaha Jun 25 '19 at 09:43
  • @ Shivendra, what I have to write here "test content" and how I have to tell this? " //number of vc_column you have a need to use, according to your requirement." – Ankit Kushwaha Jun 25 '19 at 11:01
  • I'm asking just for my Info. What do you want to display on page template ? – Shivendra Singh Jun 25 '19 at 11:05
  • Here is the code - It is used for Automatic writing and changing of Text [vc_row][vc_column][ultimate_fancytext strings_textspeed="35" strings_backspeed="0" fancytext_strings="Welcome Namaste Wellkumma Шъукъеблагъ iHola! Shagotom आईं ना Tusanyuse okubalaba" strings_font_size="desktop:60px;"][/vc_column][/vc_row] – Ankit Kushwaha Jun 25 '19 at 11:27
  • I edit the code please check. process will be same. [ultimate_fancytext strings_textspeed="35" strings_backspeed="0" fancytext_strings="Welcome Namaste Wellkumma Шъукъеблагъ iHola! Shagotom आईं ना Tusanyuse okubalaba" strings_font_size="desktop:60px;"] is coming form post? – Shivendra Singh Jun 25 '19 at 11:44
  • Its working. But the animation style is changed.. Its typing all the words and then its deleting. It should be like One word type, then delete, then another type at the same place. So, this is the basic idea you have suggested. I can use any Visual composer by these codes? – Ankit Kushwaha Jun 25 '19 at 11:59
  • Maybe some jquery or css file is missing for ultimate_fancytext. Did you inclde get_footer() function in template file. – Shivendra Singh Jun 25 '19 at 12:07
  • No.. I don't know about that. Well, what's the use of get_footer() function? – Ankit Kushwaha Jun 25 '19 at 12:13
  • If you don't add the get_footer() in template file, Whatever js file included in footer will work. Please add and check – Shivendra Singh Jun 25 '19 at 12:19
  • I have to add in the same php file in which I have written that code? Also, one more thing.. what I have to write. Sorry but, I am completely new in PHP. – Ankit Kushwaha Jun 25 '19 at 12:32
  • Please check this to create page template in wordpress - https://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/ – Shivendra Singh Jun 25 '19 at 12:35
  • I have already created homepage in theme template. Still, I will read your tutorial for custom pages. Thanks a lot. :) – Ankit Kushwaha Jun 25 '19 at 13:52
  • Well Its working now the way I want. But Shivendra, Text Size is constant. I changed that 60px value. But nothing happened. – Ankit Kushwaha Jun 25 '19 at 18:13