在页脚中使用Visual Composer行

时间:2018-12-11 13:34:46

标签: php wordpress shortcode visual-composer

我们有一个使用Visual Composer插件构建的Wordpress网站。

我们的客户喜欢其中一个小部件,并希望将其放在每个页面的页脚中,但是由于我们也使用Woocommerce,因此无法将它们编辑为经典的VC Wordpress页面。

我们认为可以在footer.php中添加相同的简码,所以我复制了该小部件的VC简码,并将其放在php行之间,然后将其粘贴到footer.php:

<?php echo do_shortcode("<p>[vc_row rt_row_background_width="fullwidth" rt_row_content_width="default" rt_row_style="light-style" rt_row_height="" rt_column_gaps="" rt_row_shadows="" rt_row_borders="" rt_bg_effect="parallax" rt_bg_parallax_effect="4" rt_bg_image_repeat="repeat" rt_bg_size="cover" rt_bg_position="center center" rt_bg_layer="" rt_bg_video_format="self-hosted" rt_row_paddings="true" rt_padding_top="105" rt_padding_bottom="80" rt_bg_image="5130" rt_class="rt-6950250" rt_paddings="80,80,," rt_margins=",,," rt_content_margins=",,," rt_tablet_paddings=",,," rt_tablet_margins=",,," rt_tablet_content_margins=",,," rt_sp_paddings=",,," rt_sp_margins=",,," rt_sp_content_margins=",,,"][vc_column rt_bg_effect="classic" rt_bg_image_repeat="repeat" rt_bg_size="auto auto" rt_bg_position="right top" rt_bg_attachment="scroll" rt_col_paddings="true" rt_wrp_col_paddings="false" rt_padding_left="15%" rt_padding_right="15%" rt_bg_color="" rt_bg_overlay_color="" rt_class="rt-1199465" rt_margins="," rt_paddings=",,15%,15%" rt_wrapper_paddings=",,," rt_tablet_margins="," rt_tablet_paddings=",,," rt_tablet_wrapper_paddings=",,," rt_sp_margins="," rt_sp_paddings=",,20,20" rt_sp_wrapper_paddings=",,,"][rt_heading style="style-4" size="h4" font_color_type="" font="" custom_font_size="" link="" link_open="_self" punchline="" rt_class="rt-8254094"]Markalarımız[/rt_heading][vc_column_text 0=""]</p>
<p style="text-align: center;">1972 yılında Küçükpazar'da temeli atılan ticarethanemiz, Tahtakale'den sonra İstoç 26.Ada no:31-33 Mahmutbey Bağcılar İSTANBUL adresinde EMRE GIDA PAZ. SAN.VE DIŞ TİC.LTD ŞTİ olarak; değerli müşterilerimize ANCHOR, MASK ve BUTTERFLY markalı ürünlerimizi tedarik edip en uygun fiyata sunmaya devam etmektedir.</p>
<p>[/vc_column_text][vc_empty_space height="30px"][rt_photo_gallery image_ids="5123,5127,5358" layout_style="grid" image_size="rtframework_retina" item_width="1/3" nogaps="true" links="false" captions="false"][/vc_column][/vc_row][vc_row rt_row_background_width="fullwidth" rt_row_content_width="default" rt_row_style="default-style" rt_row_height="" rt_column_gaps="" rt_row_shadows="" rt_row_borders="" rt_bg_effect="classic" rt_bg_image_repeat="repeat" rt_bg_size="cover" rt_bg_position="right top" rt_bg_attachment="scroll" rt_bg_layer="" rt_bg_video_format="self-hosted"][vc_column rt_bg_effect="classic" rt_bg_image_repeat="repeat" rt_bg_size="auto auto" rt_bg_position="right top" rt_bg_attachment="scroll"][vc_column_text]</p>
<p>' );?>[/vc_column_text][/vc_column][/vc_row]</p>"); ?>

但是,页脚未加载。

原始小部件的简码:

<p>[vc_row rt_row_background_width="fullwidth" rt_row_content_width="default" rt_row_style="light-style" rt_row_height="" rt_column_gaps="" rt_row_shadows="" rt_row_borders="" rt_bg_effect="parallax" rt_bg_parallax_effect="4" rt_bg_image_repeat="repeat" rt_bg_size="cover" rt_bg_position="center center" rt_bg_layer="" rt_bg_video_format="self-hosted" rt_row_paddings="true" rt_padding_top="105" rt_padding_bottom="80" rt_bg_image="5130" rt_class="rt-6950250" rt_paddings="80,80,," rt_margins=",,," rt_content_margins=",,," rt_tablet_paddings=",,," rt_tablet_margins=",,," rt_tablet_content_margins=",,," rt_sp_paddings=",,," rt_sp_margins=",,," rt_sp_content_margins=",,,"][vc_column rt_bg_effect="classic" rt_bg_image_repeat="repeat" rt_bg_size="auto auto" rt_bg_position="right top" rt_bg_attachment="scroll" rt_col_paddings="true" rt_wrp_col_paddings="false" rt_padding_left="15%" rt_padding_right="15%" rt_bg_color="" rt_bg_overlay_color="" rt_class="rt-1199465" rt_margins="," rt_paddings=",,15%,15%" rt_wrapper_paddings=",,," rt_tablet_margins="," rt_tablet_paddings=",,," rt_tablet_wrapper_paddings=",,," rt_sp_margins="," rt_sp_paddings=",,20,20" rt_sp_wrapper_paddings=",,,"][rt_heading style="style-4" size="h4" font_color_type="" font="" custom_font_size="" link="" link_open="_self" punchline="" rt_class="rt-8254094"]Markalarımız[/rt_heading][vc_column_text 0=""]</p>
<p style="text-align: center;">1972 yılında Küçükpazar'da temeli atılan ticarethanemiz, Tahtakale'den sonra İstoç 26.Ada no:31-33 Mahmutbey Bağcılar İSTANBUL adresinde EMRE GIDA PAZ. SAN.VE DIŞ TİC.LTD ŞTİ olarak; değerli müşterilerimize ANCHOR, MASK ve BUTTERFLY markalı ürünlerimizi tedarik edip en uygun fiyata sunmaya devam etmektedir.</p>
<p>[/vc_column_text][vc_empty_space height="30px"][rt_photo_gallery image_ids="5123,5127,5358" layout_style="grid" image_size="rtframework_retina" item_width="1/3" nogaps="true" links="false" captions="false"][/vc_column][/vc_row][vc_row rt_row_background_width="fullwidth" rt_row_content_width="default" rt_row_style="default-style" rt_row_height="" rt_column_gaps="" rt_row_shadows="" rt_row_borders="" rt_bg_effect="classic" rt_bg_image_repeat="repeat" rt_bg_size="cover" rt_bg_position="right top" rt_bg_attachment="scroll" rt_bg_layer="" rt_bg_video_format="self-hosted"][vc_column rt_bg_effect="classic" rt_bg_image_repeat="repeat" rt_bg_size="auto auto" rt_bg_position="right top" rt_bg_attachment="scroll"][vc_column_text]</p>
<p>' );?>[/vc_column_text][/vc_column][/vc_row]</p>

有人可以帮我吗?

3 个答案:

答案 0 :(得分:0)

您遇到任何错误吗?

但是最后一行至少是错误的。

<p>' );?>[/vc_column_text][/vc_column][/vc_row]</p>"); ?>

我认为您必须删除');该行中的?>,因为它无法运行do_shortcode()函数。像这样:

<p>[/vc_column_text][/vc_column][/vc_row]</p>"); ?>

答案 1 :(得分:0)

首先,一般而言,射击代码中不使用任何标签。 它们看起来像

=countifs('sheet1'!a:a, 0, 'sheet1'!b:b, "=")

仔细查看[文档] [1]。 当您在wordpress系统的后端打开页面并以“经典模式”进行查看时,就会显示您的简码。

对于您的问题,this可能会有所帮助。

但是也许这对您来说更容易: 只需检查(右键单击>显示源代码)您已经在使用页脚的页面即可。
然后将页脚的html复制到模板文件(footer.php)。

有关vc img元素的示例,请参见html代码(您可以检查):

 [contact-form-7 id="91" title="quote"]

提到的另一种选择:只需使用vc类即可。

答案 2 :(得分:0)

并不是所有页面都初始化了Visual Composer,您可能需要从主题函数中调用资产:

add_action( 'wp_enqueue_scripts', 'add_wpbakery_assets' );

function add_wpbakery_assets() {
    wp_enqueue_script( 'wpb_composer_front_js' );
    wp_enqueue_style( 'js_composer_front' );
    wp_enqueue_style( 'js_composer_custom_css' );
}

执行@Stender的建议可能更容易,并且可以在VC页面中呈现代码,然后只需将HTML复制到页脚即可。