How To Make Term Edition Easier
Using the following snippet, you will be able to make term edition easier.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
if ( !function_exists('edit_term_link') ) { function edit_term_link( $link = '', $before = '', $after = '', $term = null ) { if ( $term == null ) { global $wp_query; $term = $wp_query->get_queried_object(); } $tax = get_taxonomy( $term->taxonomy ); if ( !current_user_can($tax->cap->edit_terms) ) return; if ( empty($link) ) $link = __('Edit This'); $link = '<a href="' . get_edit_tag_link( $term->term_id, $term->taxonomy ) . '" title="' . $link . '">' . $link . '</a>'; echo $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; } } |
Once saved, add the following line of snippet on any category, tag or taxonomy template:
1 |
<?php edit_term_link(); ?> |
Snippet Source/Credit: Joost de Valk
How To Set A Maximum Word Count On Post Titles
Adding the following snippet to your theme’s functions.php file, you will be able to set a maximum word count on post titles.
1 2 3 4 5 6 7 |
function maxWord($title){ global $post; $title = $post->post_title; if (str_word_count($title) >= 10 ) //set this to the maximum number of words wp_die( __('Error: your post title is over the maximum word count.') ); } add_action('publish_post', 'maxWord'); |
Snippet Source/Credit: Pippin
How To Rearrange WordPress Categories Order
Using the following snippet, you will be able to rearrange WordPress categories order.
1 2 3 4 5 6 7 8 9 10 11 |
<?php $categories = get_terms('books_category'); for( $i=0; $i<sizeof($categories); $i++ ){ if ( $categories[$i]->name == 'New Publications' ) : $latest = array($categories[$i]); unset($categories[$i]); endif; } if( isset($latest) ) array_splice( $categories, 0, 0, $latest ); ?> |
Snippet Source/Credit: Sebastian
How To Remove WordPress Version Number
Using the following snippet, you will be able to remove WordPress version number.
1 2 3 4 |
add_filter('the_generator', 'digwp_complete_version_removal'); function digwp_complete_version_removal() { return ''; } |
Snippet Source/Credit: Jeff Starr
How To Easily Get Post Content By ID
Using the following snippet will let you easily get post content by ID. All you have to do is to simply use the get_post_field() function to get the post content and you are done.
1 |
echo get_post_field('post_content', $post_id); |
How To Prevent WordPress To Compress Your JPG Files
The following snippet will let you prevent WordPress to compress your JPG files.
1 |
add_filter('jpeg_quality', function($arg){return 100;}); |
Snippet Source/Credit: WP Snippets