do_action( 'init' )
Fires after WordPress has finished loading but before any headers are sent.
EX 1
add_action('init', 'my_php_function');
function my_php_function() {
if (stripos($_SERVER['REQUEST_URI'], 'page-with-custom-php') !== false) {
// add desired php code here
}
}
Insert PHP code In Wordpress Page and Post : stack overflow : https://stackoverflow.com/questions/18896146/insert-php-code-in-wordpress-page-and-post
EX 2
add_action('init', 'my_function');
function my_function() {
if (!is_user_logged_in()) {
?>
<style>
.selector {}
</style>
<?php
}
}
'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] is_user_logged_in() (0) | 2018.07.08 |
[Wordpress] wp_head action hook (0) | 2018.07.08 |