dov11020 2017-06-20 18:42
浏览 38

徽标未显示在菜单中

In my WordPress menu, I have a logo that is set as the first list item. It is showing up fine on home page, but on all other pages it does not show up. This is because the url for the image is different on home page than all other pages. Look at pictures for better understanding. what I currently have the url set to. Url on pages other than home page As you can see, on pages other than homepage, the correct url should have the page slug. I'm not sure how to go about putting the slug into the current url on my menu. Thanks in advance!

    <?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Revived_Furnishings
 */

?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">

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

<body <?php body_class(); ?>>
<div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'revivedfurnishings' ); ?></a>

    <header id="masthead" class="site-header" role="banner">

        <nav id="site-navigation" class="main-navigation" role="navigation">

        <img class="mobile-logo" src="wp-content/themes/revivedfurnishings/images/logo.jpg">

            <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( '', 'revivedfurnishings' ); ?>Menu</button>
            <?php wp_nav_menu( array( 'theme_location' => 'menu-1', 'menu_id' => 'primary-menu' ) ); ?>
        </nav><!-- #site-navigation -->
    </header><!-- #masthead -->

    <div id="content" class="site-content">
  • 写回答

2条回答 默认 最新

  • dongzhang1875 2017-06-20 22:43
    关注

    I am not sure why you would put a logo in as a menu item. It would be better to put it directly in your header.php file. However if you are not accustomed with editing wordpress themes then all you have to do is add a / at the beginning of your image src. This means the URL src will be treated as a root path and won't be appended to the end of the current pages URL.

    <img class="logo" src="/wp-content/themes/revivedfurnishings/images/logo.jpg"> 
    

    UPDATE: This should allow you to add a logo to your header navigation. What I am doing here is adding the 'container' => false argument to the wp_nav_menu function so it does not include the <ul></ul> wrapper. You can then add your own <ul></ul> wrapper and add your own link/img.

    <ul>
    <li><a href="/"><img class="logo" src="<?php echo get_template_directory_uri(); >/wp-content/themes/revivedfurnishings/images/logo.jpg"></a></li>
    <?php wp_nav_menu( 
      array( 
        'theme_location' => 'menu-1', 
        'menu_id' => 'primary-menu', 
        'container' => false 
      ) 
    ); ?>
    </ul>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探