2013-01-05 53 views
2

感謝您花時間閱讀此內容。我的標題幾乎總結了我遇到的問題。通常我會通過這些類型的東西摸索我的方式,但最終會以錯誤的方式完成,因此我的網站最終會遇到問題。我正在嘗試學習正確的方式來編碼所有內容,並讓它變得更好,更乾淨。在主菜單下的標題中添加徽標

這是我使用的WordPress模板。這是一個鏈接到我的site。我已經設置了一個兒童主題,並且像大多數目前看起來一樣,除了我想在「菜單 - 主」下的所有頁面上放置網站標誌,因爲它是在標題中調用。在頁面的左上角是我的網站標題和我的網站標語或任何你稱之爲的地方。下面是我的菜單(menu-primary),所有提到的內容都屬於標題。我的模板不允許我在設置或自定義中的標題中插入徽標。我想在菜單部分正下方的頁面中間插入一個站點徽標。我想我應該可以點擊我的主頁或其他東西,並確保它是一個有效的XHTML clickable header image?我不確定這是不是一個好主意,或者沒有看到網站標題會鏈接回主頁。有兩個鏈接到我的所有網頁上的同一個地方是不好的?我假設如此。我並不需要這個圖片來鏈接我的猜測。

有沒有人可以幫助我呢?我很欣賞所有的輸入。這個網站對教我的基礎知識非常有幫助。我看到了在這裏做我想做的事的方法,但我擔心它們都不是正確的做法。再次感謝!

這裏是header.php文件:

<?php 
/** 
* Header Template 
* 
* The header template is generally used on every page of your site. Nearly all other templates call it 
* somewhere near the top of the file. It is used mostly as an opening wrapper, which is closed with the 
* footer.php file. It also executes key functions needed by the theme, child themes, and plugins. 
* 
* @package Save for Web 
* @subpackage Template 
*/ 
?> 
<!DOCTYPE html> 
<html <?php language_attributes(); ?>> 
<head> 
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> 
<title><?php hybrid_document_title(); ?></title> 

<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="all" /> 
<link rel="profile" href="http://gmpg.org/xfn/11" /> 
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 

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

</head> 

<body class="<?php hybrid_body_class(); ?>"> 

    <?php do_atomic('open_body'); // saveforweb_open_body ?> 

    <div id="container"> 

     <?php do_atomic('before_header'); // saveforweb_before_header ?> 

     <div id="header"> 

      <div class="fixed"> 

       <?php do_atomic('open_header'); // saveforweb_open_header ?> 

       <div class="wrap"> 

        <div id="branding"> 
         <?php hybrid_site_title(); ?> 
         <?php hybrid_site_description(); ?> 
        </div><!-- #branding --> 

        <?php get_template_part('menu', 'primary'); // Loads the menu-primary.php template. ?> 

        <?php get_sidebar('header'); // Loads the sidebar-header.php template. ?> 

        <?php do_atomic('header'); // saveforweb_header ?> 

       </div><!-- .wrap --> 

       <?php do_atomic('close_header'); // saveforweb_close_header ?> 

      </div><!-- .fixed --> 

     </div><!-- #header --> 

     <?php do_atomic('after_header'); // saveforweb_after_header ?> 

     <?php do_atomic('before_main'); // saveforweb_before_main ?> 

     <div id="main"> 

      <div class="wrap"> 

      <?php do_atomic('open_main'); // saveforweb_open_main ?> 

這裏是菜單primary.php:

<?php 
/** 
* Primary Menu Template 
* 
* Displays the Primary Menu if it has active menu items. 
* 
* @package Save for Web 
* @subpackage Template 
*/ 

if (has_nav_menu('primary')) : ?> 

    <?php do_atomic('before_menu_primary'); // saveforweb_before_menu_primary ?> 

    <div id="menu-primary" class="menu-container"> 

      <?php do_atomic('open_menu_primary'); // saveforweb_open_menu_primary ?> 

      <?php wp_nav_menu(array('theme_location' => 'primary', 'container_class' => 'menu', 'menu_class' => '', 'menu_id' => 'menu-primary-items', 'fallback_cb' => '')); ?> 

      <?php do_atomic('close_menu_primary'); // saveforweb_close_menu_primary ?> 

    </div><!-- #menu-primary .menu-container --> 

    <?php do_atomic('after_menu_primary'); // saveforweb_after_menu_primary ?> 

<?php endif; ?> 
+0

我們很難回答你的問題,而不知道這個主題是如何放在一起的。您可能需要編輯具有該菜單代碼的任何模板文件,然後將徽標添加到該文件的末尾。它不應該很難,但除非我們有更多的信息,否則我不認爲這是我們可以幫助你的東西。 –

+0

我試圖描述如何做@ChrisHerbert推薦的東西。我想說我不確定你可以給我們什麼其他信息。我認爲你的問題甚至可以更簡潔。但是,由於我們沒有模板,所以我們不能告訴你怎麼做,這是問題的本質。 –

+0

感謝大家的回覆!克里斯,什麼樣的額外信息會有幫助?我做了一個包括header.php的編輯,希望這有助於。 – bc05

回答

1

生成菜單對你來說是最有可能wp_nav_menu功能。所以第一步是找出它在模板源代碼中的位置。例如,可能在header.php中。確保它的參數是「theme_location =>'menu-primary'」,這樣你就有了正確的菜單,以防你的模板有幾個。

接下來,複製該代碼和它下面粘貼:

<a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/..." alt="" title="" /></a> 

你將不得不調整SRC = ...部分,以便使其對你的頭圖像的URL匹配。

+0

嘿Calle!謝謝回覆。我編輯了上面的問題,幷包含header.php和menu-primary.php。 menu-primary.php是wp_nav_menu所在的位置。我添加了您建議的代碼(未在我的編輯中顯示),但我沒有看到任何更改。有任何想法嗎?感謝您的時間和耐心。 – bc05

+0

查看網站的源代碼(在瀏覽器中點擊右鍵,查看源代碼),圖像應該在哪裏。那裏有img標籤嗎?是