Last active
August 29, 2015 14:12
-
-
Save jepser/e1bfd8540838f558f812 to your computer and use it in GitHub Desktop.
Filter and Hook WordPress example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_single_background(){ | |
$id = get_the_id(); | |
$bg = get_post_meta($id, 'background', true); | |
if($bg){ | |
?> | |
<style> | |
body{ | |
background-image: url(<?php echo $bg; ?>); | |
} | |
</style> | |
<?php | |
} | |
} | |
add_action('wp_enqueue_scripts', 'add_single_background'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/$content contiene el contenido que está guardado en el artículo | |
function append_author($content){ | |
$author = get_the_author(); | |
$content .= '<div class="by_author">' . __('Wrote the dedication by: ') . $author . '</div>'; | |
return $content; | |
} | |
add_filter('the_content', 'append_author'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment