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 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 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 Create Page On Theme Activation In WordPress
Using the following snippet, you will be able to create page on theme activation in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
if (isset($_GET['activated']) && is_admin()){ $new_page_title = 'This is the page title'; $new_page_content = 'This is the page content'; $new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template. //don't change the code bellow, unless you know what you're doing $page_check = get_page_by_title($new_page_title); $new_page = array( 'post_type' => 'page', 'post_title' => $new_page_title, 'post_content' => $new_page_content, 'post_status' => 'publish', 'post_author' => 1, ); if(!isset($page_check->ID)){ $new_page_id = wp_insert_post($new_page); if(!empty($new_page_template)){ update_post_meta($new_page_id, '_wp_page_template', $new_page_template); } } } |
Snippet Source/Credit: WPCanyon.com
How To Automatically Link Twitter Usernames In WordPress Posts
Using the following snippet, you will be able to automatically link Twitter usernames in WordPress posts.
1 2 3 4 5 |
function content_twitter_mention($content) { return preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/', "$1@$2", $content); } add_filter('the_content', 'content_twitter_mention'); add_filter('comment_text', 'content_twitter_mention'); |
Snippet Source/Credit: Paulund.co.uk
How To Add A Logo To A Template
Using the following snippet, you will be able to add a logo to a template.
1 |
<img src="<?php echo get_stylesheet_directory_uri()?>/images/logo.png" alt="My Logo"> |
Snippet Source/Credit: WPSnipp