How To Create Custom Terms Admin Column In WordPress
Using the following snippet, you will be able to create custom terms admin column in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// for pages add_filter('manage_pages_columns', 'term_columns_id', 5); add_action('manage_pages_custom_column', 'term_custom_id_columns', 5, 2); // for posts add_filter('manage_posts_columns', 'term_columns_id', 5); add_action('manage_posts_custom_column', 'term_custom_id_columns', 5, 2); function term_columns_id($defaults){ $defaults['wps_post_type'] = __('Term'); return $defaults; } function term_custom_id_columns($column_name, $id){ if($column_name === 'wps_post_type'){ echo the_terms( $id, 'TERM_NAME', '', ', ' ); } } |
Snippet Source/Credit: WP-Snipp
How To Block Admin For All Users In WordPress
Using the following snippet you will be able to block admin for all users in WordPress.
1 2 3 4 5 6 7 |
add_action( 'init', 'blockusers_wps_init' ); function blockusers_wps_init() { if ( is_admin() && ! current_user_can( 'administrator' ) ) { wp_redirect( home_url() ); exit; } } |
Snippet Source/Credit: WPSnipp
How To Delete Links In Comments In WordPress
Using the following snippet, you will be able to delete links in comments in WordPress.
1 2 3 4 5 6 |
function delete_comment_link($id) { if (current_user_can('edit_post')) { echo '| <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&c='.$id.'">borrar</a> '; echo '| <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&dt=spam&c='.$id.'">spam</a>'; } } |
Snippet Source/Credit: Snipplr
How To Display Posts In Random Order In WordPress
Using the following snippet, you will be able to display posts in random order in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
session_start(); add_filter( 'posts_orderby', 'randomise_with_pagination' ); function randomise_with_pagination( $orderby ) { if( is_front_page() ) { // Reset seed on load of initial archive page if( ! get_query_var( 'paged' ) || get_query_var( 'paged' ) == 0 || get_query_var( 'paged' ) == 1 ) { if( isset( $_SESSION['seed'] ) ) { unset( $_SESSION['seed'] ); } } // Get seed from session variable if it exists $seed = false; if( isset( $_SESSION['seed'] ) ) { $seed = $_SESSION['seed']; } // Set new seed if none exists if ( ! $seed ) { $seed = rand(); $_SESSION['seed'] = $seed; } // Update ORDER BY clause to use seed $orderby = 'RAND(' . $seed . ')'; } return $orderby; } |
Snippet Source/Credit: Snipplr