Agganciare wp_head(); in un plugin
9 nov 2014, 19:19:27
Visualizzazioni: 20.9K
Voti: 5
Sto seguendo un tutorial che richiede di inserire questo codice sopra wp_head();
<?php
$example_position = get_theme_mod( 'logo_placement' );
if( $example_position != '' ) {
switch ( $example_position ) {
case 'left':
// Non fare nulla. Il tema già allinea il logo a sinistra
break;
case 'right':
echo '<style type="text/css">';
echo '#main-header #logo{ float: right; }';
echo '</style>';
break;
case 'center':
echo '<style type="text/css">';
echo '#main-header{ text-align: center; }';
echo '#main-header #logo { text-align: center; float: none; margin: 0 auto; display:block; }';
echo '</style>';
break;
}
}
?>
Speravo di poterlo agganciare in qualche modo da un plugin. Dopo aver controllato il codex, speravo di poter fare qualcosa del genere ma non funziona.
add_action('wp_head','hook_header');
function hook_header()
{
$output="<?php
$example_position = get_theme_mod( 'logo_placement' );
if( $example_position != '' ) {
switch ( $example_position ) {
case 'left':
// Non fare nulla. Il tema già allinea il logo a sinistra
break;
case 'right':
echo '<style type="text/css">';
echo '#main-header #logo{ float: right; }';
echo '</style>';
break;
case 'center':
echo '<style type="text/css">';
echo '#main-header{ text-align: center; }';
echo '#main-header #logo { text-align: center; float: none; margin: 0 auto; display:block; }';
echo '</style>';
break;
}
}
?>";
echo $output;
}
Tutte le risposte alla domanda
1
0
Hai provato questo?
function hook_header() {
$example_position = get_theme_mod( 'logo_placement' );
if( $example_position != '' ) {
switch ( $example_position ) {
case 'left':
// Non fare nulla. Il tema allinea già il logo a sinistra
break;
case 'right':
echo '<style type="text/css">';
echo '#main-header #logo{ float: right; }';
echo '</style>';
break;
case 'center':
echo '<style type="text/css">';
echo '#main-header{ text-align: center; }';
echo '#main-header #logo { text-align: center; float: none; margin: 0 auto; display:block; }';
echo '</style>';
break;
}
}
}
add_action('wp_head','hook_header');

shanebp
5.08K
9 nov 2014 19:31:57
Domande correlate