Skip to content

Instantly share code, notes, and snippets.

@hmowais
Last active November 21, 2019 12:32
Show Gist options
  • Save hmowais/006e22e71a0be64c66509adb6fbe6d6f to your computer and use it in GitHub Desktop.
Save hmowais/006e22e71a0be64c66509adb6fbe6d6f to your computer and use it in GitHub Desktop.
Schema Visual Composer Element
<?php
/**/
// include vc_schema.php file in functions.php
require_once get_template_directory() . '/vc_schema.php';
<?php
// Create vc_schema.php file on theme root [where (style.css) have found]
function faq_schema_section( $atts, $content){
$atts = shortcode_atts(
array(
'faq_list' => '',
),
$atts,
'vcas_title'
);
ob_start();
$faqList = vc_param_group_parse_atts($atts['faq_list']);
?>
<div class="faq-container" itemscope="" itemtype="http://schema.org/FAQPage">
<?php foreach ($faqList as $list) { ?>
<div class="faq-list" itemprop="mainEntity" itemscope="" itemtype="http://schema.org/Question">
<h4 itemprop="name"> <?php echo $list['faq_title']; ?></h4>
<div class="faq-content" itemscope="" itemprop="acceptedAnswer" itemtype="http://schema.org/Answer">
<div itemprop="text">
<p>
<?php echo $list['faq_content']; ?>
</p>
</div>
</div>
</div>
<?php } ?>
</div>
<?php
$myVariable = ob_get_clean();
return $myVariable;
}
add_shortcode( 'faq_schema_shortcode','faq_schema_section' );
// visual composer home page slider
function vcas_component_for_home() {
vc_map( array(
"name" => __( "FAQ Schema List", "my-text-domain" ),
"base" => "faq_schema_shortcode",
"class" => "",
"category" => __( "Schema Component", "my-text-domain"),
'icon' => get_template_directory_uri().'/assets/img/vc-icon.png',
"params" => array(
array(
'type' => 'param_group',
'value' => '',
'heading' => __( 'Faq List', 'pt-vc' ),
'param_name' => 'faq_list',
// Note params is mapped inside param-group:
'params' => array(
array(
'type' => 'textarea',
'value' => 'Heading',
'heading' => __( 'Faq Title', 'pt-vc' ),
'param_name' => 'faq_title',
),
array(
"type" => "textarea", //textarea_html, exploded_textarea,textarea
"holder" => "div",
"class" => "",
"heading" => __( "Faq Content", "my-text-domain" ),
"param_name" => "faq_content",
"value" => __( "I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "my-text-domain" ),
"description" => __( "Write article short description", "my-text-domain" ),
'group' => 'Content',
),
)
)
)
) );
}
add_action( 'vc_before_init', 'vcas_component_for_home' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment