What I am trying to get? I'm creating an Elementor custom widget. which will output a list of posts of a specific post type. Thus far everything is ok. I'm getting all I need. But the issue is, I have to output post content with its Elementor customization(created with Elementor). I've used WP_Query and get_posts(). all I get is raw HTML without any Elementor customization classes 😓. Please check the image
What I've done?
public function wp_post_list($slug_name,$order='ASC',$orderby='date'){
$args = [
'post_type' => $slug_name,
'posts_per_page' => -1,
'orderby' => $orderby,
'order' => $order,
];
return $all_posts = new \WP_Query($args);
}
public function post_list($slug_name,$order='ASC',$orderby='date'){
$args = [
'post_type' => $slug_name,
'posts_per_page' => -1,
'orderby' => $orderby,
'order' => $order,
];
$all_posts = get_posts($args);
return $all_posts;
}
public function skin_time_line($slug){
$st = $this->get_settings_for_display();
$order = $st['post_order'];
$orderby = $st['post_orderby'];
$posts = $this->post_list($slug,$order,$orderby);
$all_posts = $this->wp_post_list($slug,$order,$orderby);
echo '<div class="time_line">';
foreach($posts as $post){
echo '<div class="time_line_post">';
echo '<div class="tl_content">'.$post->post_content.'</div>';
//Getting just the HTML without any class
echo '</div>';
}
echo '</div>';
//or With WP_Query
echo '<div class="content">';
$all_posts = $this->wp_post_list($slug,$order,$orderby);
if ($all_posts->have_posts()) :
while ($all_posts->have_posts()) : $all_posts->the_post();
the_content(); // Getting just the HTML without any class
endwhile;
endif;
echo '</div>';
echo '</div>';
}
Please help! Any kind of suggestion or documentation would be appreciated.