If you want to change user color scheme for all users on your site and change user experience. You can change default admin color scheme without any plugin. You need need to add small code snippet into your theme’s functions.php file. You can find this file in your theme folder.
Open functions.php file and put following code in that file.
There are many wordpress admin related methods and code snippet written in my site. simply use search functionality for more code snippets or check wordpress tutorials section.
There are many wordpress plugin which will give you the post views using custom tables. But here using following code you can track the post views of your wp site.
Using external plugin, you can get the views and report but it will add more sql quries and extra load to your site. So I suggest use following code for getting the post views.
Count post views without wordpress plugin
Following code will track post views or count views of your wp site. You just need to copy and paste the following code into functions.php file first.
After adding the above code for tracking the post views you need to add following code into single.php file. Note: add following code inside the wp post loop.
<?php
setPostViews(get_the_ID());
?>
For showing the post views you need to put following code in single.php file. Note: add following code inside the wp post loop.
<?php
echo getPostViews(get_the_ID());
?>
Ref taken from: http://wpsnipp.com/index.php/functions-php/track-post-views-without-a-plugin-using-post-meta/
Many people wants to see the number of attachments which are used for posts. In Post list page people wants to see the number of image and other attachments. Using following code you will be able to see the attachment count in post list section.
image attachments count in Post
You just need to copy and paste the following code into functions.php file.
Many wordpress website users allow user to register on there site. After new user registration if we want to show them specific instructions or registration success page then you can use the following code. Put following code into functions.php file.
In this article I explained you about how can we redirect the user after WP registration and send user to specific page.
WP registration send user to specific page
Before adding the following code create your “registration-done” page.
In your theme code backend or plugin code you can list your wp roles. You need to display wordpress users roles many times in theme configuration and plugins page. For fetching the wp users roles you can use the following code.
If you need to show User roles in theme configuration and plugins page. For list all wordpress roles in selectbox, you can use our code.
list all wordpress roles in selectbox
$roles_obj = new WP_Roles();
$roles_names_array = $roles_obj->get_names();
echo '<select name="role">';
foreach ($roles_names_array as $role_name) {
echo '<option>'.$role_name.'</option>';
}
echo '</select>';
In new wordpress version we can add the background image or color to wordpress websites. Many older wp themes has no support for custom background functionality.
add custom background wordpress
You can very easily add the custom background support to your wordpress theme. You just need to copy following code and put in your functions.php file.
Question, how to inject html code into wordpress head section If you don’t want plugin then use code snippet for inject the code into wordpress head section.
how to inject html code into wordpress head
Many wp developers asked me same question multiple times. How to push the some HTML code into the wordpress head section. It is quite easy to push or inject the the some HTML code into the head section.There are multiple WP plugins which are giving this facility the push the HTML code into the head section. If you don’t want to use the WP plugin then you can use my code snippet for inject the code into wordpress head section.
If you are WP theme developer then you can use following code.
function WPAPI_init() {
echo "YOUR_HTML_GOES_HERE";
if (is_admin()) {
echo "YOUR_HTML_GOES_HERE";
}
}
add_action('wp_head', 'WPAPI_init');
You need to put above code into functions.php file which you find in themes folder.
If you are WP plugin developer then you can put above code into your plugin file.
WordPress tutorial, how to display your posts words count in wordpress. Here in this article we given code for adding in your theme functions.php file.
how to display your posts words count in wordpress
If you want to display the words count in your post. you should use the following code in functions.php file.
If you are not wordpress developer then dont use this code in your theme files.