Skip to content

Commit

Permalink
remove title from content added
Browse files Browse the repository at this point in the history
  • Loading branch information
Daddie2 committed Mar 26, 2024
1 parent e89063f commit 72c0141
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions widgets/Latest-Posts-Hover.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,17 @@ protected function _register_controls()
],
]
);
$this->add_control(
'remove_title',
[
'label' => esc_html__('Remove title', 'Latest-Posts-Hover'),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__('On', 'Latest-Posts-Hover'),
'label_off' => esc_html__('Off', 'Latest-Posts-Hover'),
'return_value' => 'on',
'default' => 'off',
]
);
$this->add_control(
'content_alignment',
[
Expand Down Expand Up @@ -1318,10 +1329,27 @@ protected function render()
foreach ($posts as $post) {
$post_title = get_the_title($post->ID);
if (wp_is_mobile()) {
$post_content = wp_trim_words($post->post_content, $wordMobile);
if($settings['remove_title']=='on'){
$post_content = str_replace($post_title, '', $post->post_content);
$post_content = wp_trim_words($post_content, $wordMobile);

}
if($settings['remove_title']!='on'){

$post_content = wp_trim_words($post->post_content, $wordPc);
}
} else {
if($settings['remove_title']=='on'){
$post_content = str_replace($post_title, '', $post->post_content);
$post_content = wp_trim_words($post_content, $wordPc);

}
if($settings['remove_title']!='on'){
$post_content = wp_trim_words($post->post_content, $wordPc);
}
} }
if($settings['remove_title']=='on'){
$post_content = str_replace($post_title, '', $post_content);
}
$post_date = get_the_date('j F Y', $post->ID);
$post_link = get_permalink($post->ID);
$tags = get_the_tags($post->ID);
Expand Down

0 comments on commit 72c0141

Please sign in to comment.