Removing the 'Screen options' tab You can remove the 'screen options' tab completely from your WordPress admin area by adding this to your theme's function.php file // Hide 'Screen Options' tab function remove_screen_options_tab() { return false; } add_filter('screen_options_show_screen', 'remove_screen_options_tab'); Removing the 'Help' tab You can also remove the 'Help' tab from the admin area in … Continue reading Remove the ‘screen options’ and ‘Help’ from the WordPress admin section
Category: PHP
Change the length of the excerpt in WordPress
When you want a custom length of your excerpt add this to your theme's function.php file and you can specify the number of words used in the excerpt function new_excerpt_length($length) { return 30; } add_filter('excerpt_length', 'new_excerpt_length');
Get the Youtube or Vimeo image still from the video URL with PHP
This is a handy function to retrieve the youtube of vimeo still from the video URL. To use the function you just need to pass the $url parameter to the function. The $size parameter is optional and will by default return the large image. If you pass "thumb" as size it will return a small … Continue reading Get the Youtube or Vimeo image still from the video URL with PHP
Change login session time for PHPMyAdmin
To change the time when your login session gets expired go to the root of your phpmyadmin folder and find the file config.inc.php Now search for this variable -> $cfg['LoginCookieValidity'] In my example I changed it to 5 hours. You should also check the session.gc_maxlifetime in you php.ini file. The lowest value of those two will be in … Continue reading Change login session time for PHPMyAdmin
Override the from email address and from name in WordPress
This is useful when dealing with contact forms within WordPress. Just add these lines to your theme's functions.php file and replace the variables $from_email and $from_name with your credentials. // OVERRIDE THE FROM EMAIL ADDRESS add_filter('wp_mail_from', 'new_mail_from'); add_filter('wp_mail_from_name', 'new_mail_from_name'); $from_email = "myemail@domain.com"; $from_name = "myname"; function new_mail_from($old) { return $from_email; } function new_mail_from_name($old) { return … Continue reading Override the from email address and from name in WordPress
Change domain of a wordpress website
What I find a major hassle when dealing with wordpress websites is to transfer the website from a development environment to a production environment. The domain you use in a development stage will be different from the one of the production website. Therefore you have to alter all the urls within the posts, the links … Continue reading Change domain of a wordpress website
Customize the wordpress admin and login page
Customizing the login section If you want to remove the standard WordPress logo from the admin login section you'll need to load a new CSS file and override the standard login CSS styles. // Custom WordPress Login function login_css() { wp_enqueue_style( 'login_css', get_template_directory_uri() . '/login.css' ); } add_action('login_head', 'login_css'); This will load the file login.css … Continue reading Customize the wordpress admin and login page
Customize the Standard WordPress footer text
The default WordPress footer says "Thank you for using WordPress". If you want to use wordpress for a client website, this doesn't look very professional. So lets remove that line or replace it with something else. To do this you'll need to edit your theme's functions.php file. Just add these lines to that file: // … Continue reading Customize the Standard WordPress footer text
Disable the “please update now” message on the WordPress dashboard for non-administrators
Sometimes when other people like clients need to use the admin section of your wordpress you don't always want them to be able to update to a newer version of wordpress because this can lead to problems with plugins. I you only want administrators to see the update message, add this code to your theme's … Continue reading Disable the “please update now” message on the WordPress dashboard for non-administrators
Template to redirect to child page within the menu for WordPress
I create a file named template-redirect-page.php in my theme’s folder and add this code: /* Template Name: Redirect subpage */ if (have_posts()) { while (have_posts()) { the_post(); $pagekids = get_pages("child_of=".$post--->ID."&sort_column=menu_order"); $firstchild = $pagekids[0]; wp_redirect(get_permalink($firstchild->ID)); } } If I want my parent page to redirect immediately to the subpage I select this template in the admin … Continue reading Template to redirect to child page within the menu for WordPress