WordPress Header 隨機 LOGO方法

先將以下 Javascript 放置 body 上方

 <script language="”JavaScript”">  <!–  function myBack(n) {  if(navigator.appVersion.charAt(0) <=2 &amp;&amp; navigator.appName.charAt(0) == “N”)  {  t = new Date()  t = t.getTime(); t += “”; t = t.substring(t.length-3,t.length); t = eval(t)/1000  t = Math.floor(t*n)  return t  }  else  {  t = Math.floor(Math.random()*n)  return t  }  }  var imgMax =5 //背景圖片的張數  var logo = new Array()  logo&#91;0&#93; = “<?php bloginfo(’stylesheet_directory’); ?>/images/logo000.jpg” //圖片位置  logo[1] = “<?php bloginfo(’stylesheet_directory’); ?>/images/logo001.jpg” //圖片位置  logo[2] = “<?php bloginfo(’stylesheet_directory’); ?>/images/logo002.jpg” //圖片位置  logo[3] = “<?php bloginfo(’stylesheet_directory’); ?>/images/logo003.jpg” //圖片位置  logo[4] = “<?php bloginfo(’stylesheet_directory’); ?>/images/logo004.jpg” //圖片位置  var img = myBack(imgMax);  document.write(”<style type=’text/css’>”)  document.write(”#header { background: url(”+logo[img]+”) no-repeat bottom center; }”)  document.write(”</style>”)  –>  </script>   

之後再把header.php 裡面, 就是控制 header 的那行(粗黑斜體) 註解掉…

這樣就大功告成了~~

body { background: url(“/images/kubrickbgcolor.jpg”); }

#page { background: url(“/images/kubrickbg.jpg”) repeat-y top; border: none; }

#page { background: url(“/images/kubrickbgwide.jpg”) repeat-y top; border: none; }

/* #header { background: url(“\””+logo[img]+ “\””) no-repeat bottom center; } */

#footer { background: url(“/images/kubrickfooter.jpg”) no-repeat bottom; border: none;}

You Might Also Like

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *