Functions.php : Simple Tricks

Here are some of the many custom changes you can implement through your functions.php. Please remember to create a child theme before installing these codes onto the functions.php file of your current theme.

To know how to create your own child theme, I recommend the Child Theme Configurator plugin.

When that is done, Activate your new child theme and Navigate to Appearance > Editor > functions.php

*** These changes would require a basic understanding of PHP coding. ***

WordPress has set a specific number of characters to appear before the Read More link, which redirects user to the post page. To override the default number, add the code below and change the number after the word ‘return’ to any whole number, then Save.

				
					/***** Excerpt Length and Read More link… *****/
function custom_excerpt_length( $length ) {
return 50;
}
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );
				
			

To change the 'Read More' to anything you want.

				
					function custom_read_more_link() {
return 'Your Text Here';
}
add_filter( 'the_content_more_link', 'custom_read_more_link' );
				
			

To customize your wp-login.php page. The first part of the code below is to allow to add chanes onto your style.css file while the second part is to change the WordPress logo to your own logo.

				
					<?php 
/***** Customize Style for the Login Page... *****/
function my_login_stylesheet() {
wp_enqueue_style( 'custom-login', get_stylesheet_directory_uri() . '/style.css' );
}
add_action( 'login_enqueue_scripts', 'my_login_stylesheet' );

/***** Change Login Logo *****/
function my-login-logo() { ?>
<style type="text/css">
#login h1 a, .login h1 a {
    background-image: url('/wp-content/specific-folder/logo.png');
    padding-bottom: 15px;
    width:300px; // customize this to best fit your logo dimensions
}
</style>
<?php }
add_action('login_enqueue_scripts','my-login-logo');
				
			

To hide dashboard elements…

				
					/***** HIDE POSTS on WP Dashboard *****/
function remove_menu_items() {
remove_menu_page('edit.php'); // To hide the Posts
remove_menu_page('edit-comments.php'); // To hide the Comments
remove_menu_page('edit.php?post_type=feedback'); // To hide the Feedback
}
add_action('admin_menu', 'remove_menu_items');
				
			

To use your custom short-codes on any post / page of your website. In this example, we want [phone] to be the shortcode and it will print the phone number and make it clickable.

				
					/***** HIDE POSTS on WP Dashboard *****/
function phonenumber() {
$phone = "<a href="tel:+1xxxxxxxxxx">+1 (xxx) xxx -xxxx</a>";
}
add_shortcode('phone', 'phonenumber');
				
			
If you have questions or need any help understanding and implementing these changes, please let me know at delice@wpquicksupport.com

Tools we are proud to recommend

Set an appointment with a specialist
to get the support you need.

Loading...
WP Quick Support strives to ensure the protection of your personal information through responsible practices. All personal information collected by WP Quick Support is done so exclusively with your consent, by means of a form posted on our website, an email received from you or by telephone. No information is collected automatically.