wp_head
EX1
function hook_css() {
?>
<style>
.wp_head_example {
background-color : #f1f1f1;
}
</style>
<?php
}
add_action('wp_head', 'hook_css');
EX2
function hook_javascript() {
?>
<script>
alert('Page is loading...');
</script>
<?php
}
add_action('wp_head', 'hook_javascript');
EX3
add_action('wp_head', 'add_css_head');
function add_css_head() {
if ( is_user_logged_in() ) {
?>
<style>
.selector {display:block;}
</style>
<?php
} else {
?>
<style>
.selector {display:none;}
</style>
<?php
}
}
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head
'WordPress > Action Hook, Filter Hook, Function' 카테고리의 다른 글
[Wordpress] Login/Logout Redirect (0) | 2018.11.03 |
---|---|
[Wordpress] do_shortcode() function (0) | 2018.07.08 |
[Wordpress] wp_footer() function (0) | 2018.07.08 |
[Wordpress] init hook (0) | 2018.07.08 |
[Wordpress] is_user_logged_in() (0) | 2018.07.08 |