0

Comment créer une simple fonction Wordpress dans functions.phpComment faire par exemple la fonction Wordpress pour en-tête html

Je veux faire quelque chose de fonction comme custom_header() et le code dans la fonction est

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 
<head profile="http://gmpg.org/xfn/11"> 
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> 
<title><?php bloginfo('name'); ?></title> 
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url'); ?>" /> 
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 
<?php if (is_singular() && get_option('thread_comments')) wp_enqueue_script('comment-reply'); ?> 

<?php wp_head(); ?> 
</head> 

<body <?php body_class(); ?>> 

Ainsi, dans mon header.php Je viens d'écrire <?php custom_header(); ?> au lieu de HTML codes ci-dessus.

Laissez-moi

Répondre

2

Très simple:

function custom_header(){ 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 
<head profile="http://gmpg.org/xfn/11"> 
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> 
<title><?php bloginfo('name'); ?></title> 
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url'); ?>" /> 
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 
<?php if (is_singular() && get_option('thread_comments')) wp_enqueue_script('comment-reply'); ?> 

<?php wp_head(); ?> 
</head> 

<body <?php body_class(); ?>> 
<?php 
} 
+0

Merci John. mimple simple. – kampit