Skip to content

Instantly share code, notes, and snippets.

View smileBeda's full-sized avatar
💭
I may be slow to respond.

Beda Schmid smileBeda

💭
I may be slow to respond.
View GitHub Profile
add_filter( 'init', 'custom_registered_taxonomy_admin_labels' );
function custom_registered_taxonomy_admin_labels() {
global $wp_taxonomies;
$labels = &$wp_taxonomies['your_taxonomy']->labels;//change to your taxonomy slug
$labels->name = 'NAME';
$labels->singular_name = 'SING_NAME';
$labels->add_new = 'Add NAME';
$labels->add_new_item = 'Add NAME';
$labels->edit_item = 'Edit NAME';
add_filter('get_the_excerpt', 'allow_html_in_excerpt');
function allow_html_in_excerpt($text) { // Fakes an excerpt if needed
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace('\]\]\>', ']]>', $text);
/*just add all the tags you want to appear in the excerpt --
be sure there are no white spaces in the string of allowed tags */
@smileBeda
smileBeda / gist:16fda9d82498f8406fd8e5888d78ff41
Created December 9, 2020 12:34
Remove WordPress native Excerpt Trim
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter( 'post_link', 'add_custom_base_to_post_links', 10, 3 );
function add_custom_base_to_post_links( $post_link, $post, $leavename ) {
if ( 'post' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_name . '/', '/your_custom_base/' . $post->post_name . '/', $post_link );
return $post_link;
}
add_filter( 'register_post_type_args', 'rename_registered_post_types', 999, 2 );
function rename_registered_post_types( $args, $post_type ){
if( 'post' == $post_type ){//your post type to rename
$args['rewrite']['slug'] = 'your_custom_slug';
}
return $args;
}