Skip to content

Instantly share code, notes, and snippets.

@jepser
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jepser/e1bfd8540838f558f812 to your computer and use it in GitHub Desktop.
Save jepser/e1bfd8540838f558f812 to your computer and use it in GitHub Desktop.
Filter and Hook WordPress example
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');
/$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