Seems like the remove filter doesn't work
remove_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link', 99 );
Any suggestions?
Checkout line 119 from the inc/setup.php;
function all_excerpts_get_more_link( $post_excerpt ) {
return $post_excerpt . ' [...]<p><a class="btn btn-secondary understrap-read-more-link" href="' . get_permalink( get_the_ID() ) . '">' . __( 'Read More...',
'understrap' ) . '</a></p>';
}
}
add_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link' );
That's where it's already being hooked into.
@typeplus Yes, I know. But how do you remove this custom hook from the excerpt?
You can modify or delete the filter and function starting line 97 and 119. Or if you like having redundant code just call the remove_filter without the priority.
@typeplus the remove_filter doesn't work in a child-theme. With or without the priority.
To be fair, you didn't say you were using a child theme so how could i know that? In any sense in your functions.php just override the pluggable function all_excerpts_get_more_link for instance;
function all_excerpts_get_more_link( $post_excerpt ) {
return $post_excerpt . 'whatever you want to do here';
}
add_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link' );
Just a note for the future, this function is now: understrap_all_excerpts_get_more_link
@raisonon Nice one. I have a lot of sites to update now...!
/* CUSTOMIZE EXCERPT READ MORE CONTENT
================================================== */
function all_excerpts_get_more_link( $post_excerpt ) {
return $post_excerpt . 'stuff';
}
add_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link' );
to
/* CUSTOMIZE EXCERPT READ MORE CONTENT
================================================== */
function understrap_all_excerpts_get_more_link( $post_excerpt ) {
return $post_excerpt . 'stuff';
}
add_filter( 'wp_trim_excerpt', 'understrap_all_excerpts_get_more_link' );
I'm tempted to add a pull request to take this button out permanently - It think the button is not required as a default...
I'm getting a weird duplicate button and [...] from my function. (Trying to override the Understrap
function on line 97 in my functions.php), can anyone help me understand why this would be occurring?
If I'm understanding the codex and the comments here, the button and the [...] should be getting overidden by '[TESTING]'.
Help!?
// . Post excerpt adjustment
// . ========================
add_filter( 'get_the_excerpt', function( $excerpt ) {
$excerpt_length = apply_filters( 'excerpt_length', 18 );
$excerpt_more = apply_filters( 'excerpt_more', '[TESTING]' );
$excerpt = wp_trim_excerpt( $excerpt, $excerpt_length, $excerpt_more);
return $excerpt;
}, 10, 2 );
In this theme there is another filter applied to wp_trim_excerpt. The understrap_all_excerpts_get_more_link() function found inside /inc/setup.php:
You may need to unhook that filter before you run your own.
Nailed it, Thanks bro! :) Love this framework. It's so lightweight. Although I wish there was a discord server where devs could talk and hash out questions... :)
Most helpful comment
I'm tempted to add a pull request to take this button out permanently - It think the button is not required as a default...