我一直在尝试将一些社交媒体图标(class=“penci topbar social”)移动到wp_nav_menu
元素,我被难住了。我尝试将社交媒体代码移到wp_nav_menu
数组,但这不起作用。我想我必须在functions.php
例如add_filter
, 但我不确定从哪里开始。这是php的标题,如果我们还需要发布functions.php
:
<?php
/**
* Top bar template
* Options for it in Customize > Top Bar Options & Colors For Top Bar
*
* @since 1.0
*/
?>
<div class="penci-top-bar<?php if( get_theme_mod(
\'penci_top_bar_hide_social\' ) ): echo \' no-social\'; endif; if( get_theme_mod( \'penci_top_bar_enable_menu\' ) ): echo \' topbar-menu\'; endif; if( get_theme_mod( \'penci_top_bar_full_width\' ) ): echo \' topbar-fullwidth\'; endif; ?>">
<div class="container">
<div class="penci-headline" role="navigation" itemscope itemtype="http://schema.org/SiteNavigationElement">
<?php
if( get_theme_mod( \'penci_top_bar_enable_menu\' ) ):
/**
* Display topbar menu
*/
wp_nav_menu( array(
\'container\' => false,
\'theme_location\' => \'topbar-menu\',
\'menu_class\' => \'penci-topbar-menu\',
\'fallback_cb\' => \'wp_page_menu\',
\'walker\' => \'\'
) );
endif; /* End check if topbar is enable */
?>
<?php if( penci_get_setting( \'penci_top_bar_custom_text\' ) && ! get_theme_mod( \'penci_top_bar_enable_menu\' ) ) { ?>
<span class="headline-title"><?php echo penci_get_setting( \'penci_top_bar_custom_text\' ); ?></span>
<?php } ?>
<?php if( ! get_theme_mod( \'penci_top_bar_hide_social\' ) ): ?>
<div class="penci-topbar-social">
<?php include( trailingslashit( get_template_directory() ). \'inc/modules/socials.php\' ); ?>
</div>
<?php endif; ?>
<?php
if( ! get_theme_mod( \'penci_top_bar_enable_menu\' ) ):
/**
* Display headline slider
*/
$number_posts = get_theme_mod( \'penci_top_bar_posts_per_page\' ) ? get_theme_mod( \'penci_top_bar_posts_per_page\' ) : 10;
$topbar_cat = get_theme_mod( \'penci_top_bar_category\' );
$topbar_sort = get_theme_mod( \'penci_top_bar_display_by\' );
$args = array(
\'post_type\' => \'post\',
\'posts_per_page\' => $number_posts
);
if( ! get_theme_mod( \'penci_top_bar_tags\' ) || get_theme_mod( \'penci_top_bar_filter_by\' ) != \'tags\' ) {
if ( $topbar_cat ):
$args[\'cat\'] = $topbar_cat;
endif;
} elseif ( get_theme_mod( \'penci_top_bar_tags\' ) && get_theme_mod( \'penci_top_bar_filter_by\' ) == \'tags\' ) {
$list_tag = get_theme_mod( \'penci_top_bar_tags\' );
$list_tag_trim = str_replace( \' \', \'\', $list_tag );
$list_tags = explode( \',\', $list_tag_trim );
$args[\'tax_query\'] = array(
array(
\'taxonomy\' => \'post_tag\',
\'field\' => \'slug\',
\'terms\' => $list_tags
),
);
}
if( $topbar_sort == \'all\' ) {
$args[\'meta_key\'] = \'penci_post_views_count\';
$args[\'orderby\'] = \'meta_value_num\';
$args[\'order\'] = \'DESC\';
} elseif( $topbar_sort == \'week\' ) {
$args[\'meta_key\'] = \'penci_post_week_views_count\';
$args[\'orderby\'] = \'meta_value_num\';
$args[\'order\'] = \'DESC\';
} elseif( $topbar_sort == \'month\' ) {
$args[\'meta_key\'] = \'penci_post_month_views_count\';
$args[\'orderby\'] = \'meta_value_num\';
$args[\'order\'] = \'DESC\';
}
$news = new WP_Query( $args );
if( $news->have_posts() ):
$auto_play = \'true\';
if( get_theme_mod( \'penci_top_bar_posts_autoplay\' ) ): $auto_play = \'false\'; endif;
$auto_time = get_theme_mod( \'penci_top_bar_auto_time\' );
$auto_speed = get_theme_mod( \'penci_top_bar_auto_speed\' );
$auto_time = ( is_numeric( $auto_time ) && $auto_time > 0 ) ? $auto_time : \'3000\';
$auto_speed = ( is_numeric( $auto_speed ) && $auto_speed > 0 ) ? $auto_speed : \'200\';
?>
<div class="penci-owl-carousel penci-owl-carousel-slider penci-headline-posts" data-auto="<?php echo $auto_play; ?>" data-autotime="<?php echo absint( $auto_time ); ?>" data-speed="<?php echo absint( $auto_speed ); ?>">
<?php while( $news->have_posts() ): $news->the_post();
$title_full = get_the_title();
?>
<div>
<a class="penci-topbar-post-title" href="<?php the_permalink(); ?>"><?php echo sanitize_text_field( wp_trim_words( get_the_title(), 8, \'...\' ) ); ?></a>
</div>
<?php endwhile; wp_reset_postdata(); ?>
</div>
<?php endif; /* End check if no posts */?>
<?php endif; /* End check if topbar menu is enable */?>
</div>
</div>
这是我试图操纵的菜单的图像
最合适的回答,由SO网友:danielmcclure 整理而成
很难说没有看到真实的live页面,但这可能很简单,只需在主题样式中添加以下内容即可。css文件:
.penci-topbar-social {
float:left;
}
您不必总是修改激发内容的位置,以便在页面中直观地移动显示内容的位置。