Conectarea la wp_head(); într-un plugin
9 nov. 2014, 19:19:27
Vizualizări: 20.9K
Voturi: 5
Urmez un tutorial care necesită să pun acest cod deasupra lui wp_head();
<?php
$example_position = get_theme_mod( 'logo_placement' );
if( $example_position != '' ) {
switch ( $example_position ) {
case 'left':
// Nu face nimic. Tema aliniază deja logo-ul la stânga
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;
}
}
?>
Speram că mă pot conecta la acesta cumva dintr-un plugin. După verificarea codexului, speram să pot face ceva de genul acesta, dar nu funcționează.
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':
// Nu face nimic. Tema aliniază deja logo-ul la stânga
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;
}'
Toate răspunsurile la întrebare
1
0
Ai încercat asta?
function hook_header() {
$example_position = get_theme_mod( 'logo_placement' );
if( $example_position != '' ) {
switch ( $example_position ) {
case 'left':
// Nu face nimic. Tema deja aliniază logo-ul la stânga
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
Întrebări similare
5
răspunsuri