Hi @joyously
Again thank you for your time ??.
Here is my custom WordPress widget code, this code outputs Bootstrap tabs for “experience” post type. So when the user clicks on a particular tab, it shows the respective post content (I have used the_content() function here). But when I add this widget to home page I could only see the unformatted content but not what I built on that post using Elementor page builder, HTML tags are missing in the output.
Here is the WordPress widget code –
// Adds widget: Our Experiences Section
class Ourexperiencessectio_Widget extends WP_Widget {
function __construct() {
parent::__construct(
'ourexperiencessectio_widget',
esc_html__( 'Our Experiences Section', 'textdomain' )
);
}
public function widget( $args, $instance ) {
echo $args['before_widget'];
?>
<div class="row">
<div class="col-sm-12 our-experiences-wrapper padding-0">
<ul class="nav nav-tabs nav-fill our-experiences-tabs" id="myTab" role="tablist">
<?php
$args = array(
'post_type' => 'experience',
'order' => 'ASC'
);
$loop = new WP_Query( $args );
$active = "active";
$areaselected = "true";
while ( $loop->have_posts() ) : $loop->the_post();
?>
<li class="nav-item">
<a class="nav-link <?php echo $active; ?>" id="a<?php echo get_the_ID() ?>-tab" data-toggle="tab" href="#a<?php echo get_the_ID() ?>" role="tab" aria-controls="a<?php echo get_the_ID() ?>" aria-selected="<?php echo $areaselected; ?>"><?php the_title(); ?></a>
</li>
<?php
$active = "";
$areaselected = "false";
endwhile;
?>
</ul>
<?php
wp_reset_postdata();
?>
<div class="tab-content" id="myTabContent">
<?php
$argss = array(
'post_type' => 'experience',
'order' => 'ASC'
);
$loop = new WP_Query( $argss );
$activetab = " show active";
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="tab-pane fade<?php echo $activetab; ?> our-experiences-tab-content" id="a<?php echo get_the_ID(); ?>" role="tabpanel" aria-labelledby="a<?php echo get_the_ID(); ?>-tab">
<h3>OUR EXPERIENCES</h3>
<?php the_content();?>
</div>
<?php
$activetab = "";
endwhile;
wp_reset_postdata();
?>
</div>
</div>
</div>
<?php
echo $args['after_widget'];
}
}
function register_ourexperiencessectio_widget() {
register_widget( 'Ourexperiencessectio_Widget' );
}
add_action( 'widgets_init', 'register_ourexperiencessectio_widget' );