Thursday 2 June 2016

How to add CSS in WordPress? IT NEW CODE

Sometimes need to put CSS for WordPress Admin panel but we can't put it in its core files because when ever new updates comes in WordPress Version & update it to new Version our applied CSS will be lost.
In WordPress when update it to new version new files are override to existing files.
So we need to create a function for css which describes below.

Add Following code in your Theme folder "functions.php" file.


add_action('admin_head', 'my_custom_css');

function my_custom_css() {
      echo '<style>
      <!-- Put Your CSS Here -->
      #wpfooter {
           display: none;
         }
       </style>';
}

Its Done. Now Check Your Admin panel.

here, "my_custom_css" is a function for css.
& "add_action('admin_head', 'my_custom_css');" this for call that function in header part of the page.


-----------------------------------------------
For Login page CSS use "login_head"
-----------------------------------------------
add_action('login_head', 'custom_loginlogo');

function custom_loginlogo() {
echo '';
}

-----------------------------------------------
For Whole site Frontend & backend CSS use "init"
-----------------------------------------------
add_action('init', 'my_custom_css');

function my_custom_css() {

echo ''
}

-----------------------------------------------
For User base Front End & Back End CSS use "init"
-----------------------------------------------
add_action('init', 'my_custom_css');

function my_custom_css() {
if(!current_user_can('administrator')){

//Hide Topbar
add_filter('show_admin_bar', '__return_false');

echo '';
}
}



For more Interesting, Useful Article & codes visit IT New Code.
IT NEW CODE always help you with new Developing Code.

Ankit Shah PHP Expert

IT New Code suggest a solution for your problem related to coding, Specially .PHP, Wordpress, WooCommerce, Magento, HTML and CSS. Visit Our website for Information.

0 comments:

Post a Comment

 

Copyright @ 2016 IT New Code | Developing Code | Designing Code.

Designed by: Ankit Shah