我为滑块帖子创建了一个自定义帖子类型,然后创建了一个自定义视觉作曲家元素来从该帖子类型中收集这些帖子,然后将其组合以创建一个滑块,但它不会在翻译过的网页上呈现如果我创建一个德语页面,自定义vc元素(滑块)将不会呈现或显示到该页面。有什么帮助,想法吗?
这里是vc元素
<?php class axada_custom_elements extends WPBakeryShortCode {
// Element Init
function __construct() {
add_action( 'init', array( $this, 'axada_custom_elements_mapping' ) );
add_shortcode( 'axada_slider', array( $this, 'axada_slider_html' ) );
}
// Element Mapping
public function axada_custom_elements_mapping() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map the block with vc_map()
vc_map(
array(
'name' => __('Axada Slider', 'text-domain'),
'base' => 'axada_slider',
'description' => __('Axada Slider', 'text-domain'),
'category' => __('Axada Elements', 'text-domain'),
"as_parent" => array('except' => ''), // Use only|except attributes to limit child shortcodes (separate multiple values with comma)
"content_element" => true,
"show_settings_on_create" => true,
"is_container" => true,
'icon' => get_template_directory_uri().'/img/axada-short-logo.png',
'params' => array(
array(
'type' => 'textfield',
'holder' => 'div',
'class' => 'title-class',
'heading' => __( 'Slider ID', 'text-domain' ),
'param_name' => 'slider_id',
'value' => __( '', 'text-domain' ),
'description' => __( 'Slider ID', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textfield',
'holder' => 'div',
'class' => 'title-class',
'heading' => __( 'Slider Classes', 'text-domain' ),
'param_name' => 'slider_class',
'value' => __( '', 'text-domain' ),
'description' => __( 'Slider Classes', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textfield',
'holder' => 'div',
'class' => 'title-class',
'heading' => __( 'Slider Custom Styles', 'text-domain' ),
'param_name' => 'slider_custom_styles',
'value' => __( '', 'text-domain' ),
'description' => __( 'Slider Custom Styles', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
),
)
);
}
// Element HTML
public function axada_slider_html( $atts ) {
// Params extraction
extract(
shortcode_atts(
array(
'slider_id' => '',
'slider_class' => '',
'slider_custom_styles' => '',
),
$atts
)
);
$slider_custom_styles = $slider_custom_styles !== '' ? 'style="'.$slider_custom_styles.'"' : '';
// Fill $html var with data
//query for slider
ob_start();
//query for slider
$args = array(
'post_type' => 'axada_slider',
'meta_key' => '_arrangement_value_key',
'orderby' => 'meta_value',
'order' => 'ASC',
'post_status' => 'publish',
);
$slider = new WP_Query( $args );
if ( $slider->have_posts() ) :
//start slider
?>
<section class="kenburns image-slider slider-all-controls controls-inside pt0 pb0 height-70 vid-bg bg-dark" id="home-slider-wrapper">
<ul<?php echo $slider_id !== '' ? ' id="'.$slider_id.'" ' : ' '; ?>class="slides<?php echo $slider_class !== '' ? ' '.$slider_class : ''?>"<?php echo $slider_custom_styles !== '' ? ' style="'.$slider_custom_styles.'" ' : ''; ?> >
<?php while ( $slider->have_posts() ) : $slider->the_post(); ?>
<li>
<?php if(get_post_meta( get_the_ID(), '_axada_slider_video_value_key', true ) && get_post_meta( get_the_ID(), '_axada_slider_video_value_key', true )!==''){?>
<div class="player" data-video-id="<?php echo get_post_meta( get_the_ID(), '_axada_slider_video_value_key', true ); ?>" data-start-at="0"></div>
<div class="background-image-holder bg-size-cover">
<img alt="image" class="background-image" src="<?php the_post_thumbnail_url(); ?>" />
</div>
<?php }else{ ?>
<div class="background-image-holder bg-size-cover">
<img alt="image" class="background-image" src="<?php the_post_thumbnail_url('full'); ?>">
</div>
<div class="container v-align-transform">
<div class="row text-center">
<div class="full-width divider mb-xs-64"></div>
<?php the_content(); ?>
</div>
</div>
<?php } ?>
</li>
<?php endwhile; ?>
</ul>
</section>
<?php
//end slider
endif;
return ob_get_clean();
}