Reputation: 87
I'm using WP theme with dynamically loaded posts and 3 dots in the end of the each blog post. I need to remove these 3 dots.
I tried:
In index.php
:
1.1 Manually commented dots in template. This removed dots only for first 10 posts and in another 90 post dots reamained.
1.2 I tried to use .slice(0, -3)
to cut off the dots. It didn't work for me. It worked for 10 post without (window).scroll
, but when I added it it didn't work at all.
jQuery(window).scroll(function() {
jQuery('.hideifneed').each(function(){
var text = jQuery(this).text();
var removeDots = text.slice(0, -3)
console.log(removeDots);
});
});
Input pieces of code in the end of functions.php
. None of the code below helped me.
I tried this(2.1):
function new_excerpt_more( $more ) {
return '';
}
add_filter('excerpt_more', 'new_excerpt_more');
And this(2.2):
function change_excerpt( $more ) {
if(post_type_exists('services')){
return '';
}
return '...';
}
add_filter('excerpt_more', 'change_excerpt');
And this (2.3): <?php $excerpt = get_the_excerpt(); echo $excerpt;?>
And this (2.4):
function custom_excerpt() {
$text=preg_replace( "/\\[…\\]/",'place here whatever you want to replace',get_the_excerpt());
echo '<p>'.$text.'</p>';
}
And this (2.5): <?php remove_filter('the_excerpt', 'wpautop'); ?>
And I also tried to rewrite the excerpt
function (2.6):
function wp_new_excerpt($text)
{
if ($text == '')
{
$allowed_ends = array('.', '!', '?');
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace('...', ']]>', $text);
$text = strip_tags($text);
$text = nl2br($text);
$excerpt_length = apply_filters('excerpt_length', 10000);
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[]');
$text = implode(' ', $words);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'wp_new_excerpt');
What else can I try? Do you have any ideas?
Edited: The only thing that works in my case - in admin panel > post > post settings > Excerpt Off. This removes dots only for one post, so it is not really an option
Upvotes: 1
Views: 767
Reputation: 61
For me it works this:
function new_excerpt_more($more) {
global $post;
return '';
}
add_filter('excerpt_more', 'new_excerpt_more');
Upvotes: 1