亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

在wordpress中添加幻燈片展示

系統 1738 0

我們經常會看到一些網站上漂亮的幻燈片展示模塊,之前我們介紹過 5 款WordPress推薦文章幻燈片插件 ,而本文里面,則通過詳細的教程告訴你如何為你的博客添加一個基于SmoothGallery 2.0的幻燈片展示模塊。

?

?

?


我們需要準備什么?

在開始之前我們需要先下載 SmoothGallery 2.0

?

1. 將所需文件放到合適的地方

  • 解壓下載到的smoothgallery
  • 將解壓得到的 CSS文 件夾 復制到 wordpress 目 錄 wp-content/themes/your_theme_name
  • scripts文件夾 復制到 wp-content/themes/your_theme_name

一旦我們完成這一步,我們就有了在 博客 上運行SmoothGallery的所需效果代 碼文件。

?

2. 在header部份添加調用代碼

博客 主模板代碼的Header部分添加CSS和script文件的連接,以便在博客 頁面進行調用

將以下幾行代碼添加到主模板代碼的Header部分:

?

    <!–Css SmoothGallery–>
<link rel=”stylesheet” href=”<?php bloginfo(’template_url’); ?>/css/jd.gallery.css” type=”text/css” media=”screen”/>
<!–JS Mootools–>
<script type=”text/javascript” src=”<?php bloginfo(’template_url’); ?>/scripts/mootools.v1.11.js”></script>
<!–JS SmoothGallery–>
<script type=”text/javascript” src=”<?php bloginfo(’template_url’); ?>/scripts/jd.gallery.js”></script>

  
?

當這一步完成時,你就已經可以在 博客 主題中使用SmoothGallery了。

?

3. 新建一個Gallery.php

在你的主題目錄中新建一個文件gallery.php,這個文件會幫你生成展示gallery的html代碼。

在開始這一步之前,應該認識到smoothgallery模塊的結構。

?

?

    
      
        slideshow 300x185 如何為你的wordpress主題添加幻燈片展示
      
      



<div class=”imageElement”>
<h3>Item Title</h3>
<p>Item Description</p>
<a href=”Link to Item ” title=”open image” class=”open”></a>
<img src=”Image of item” class=”full” alt=”Item Title” />
<img src=”Thumbmail of item” class=”thumbnail” alt=”thumbnail of Item Title” />
</div>
    
  
gallery.php文件包括兩部分:

(1). 初始化SmoothGallery Script (JS)

(2). 為gally生成html/php代碼

?

你可以在這里 here 下 載到gallery.php需要這段代碼,將代碼全部保存到一個新建txt文檔中,再保存為gallery.php就可以了。

?

    <!– Initialization of SmoothGallery–>
<script type=”text/javascript”>
function startGallery() {
var myGallery = new gallery($(’myGallery’),
{timed: true});}
window.addEvent(’domready’,startGallery);
</script>
<!– Creation of the html for the gallery –>
<div class=”content”>
<div id=”myGallery”>
<!–
Get the 5 lasts posts of category which ID is 3
(to show the recent post use query_posts(’showposts=5′);)
–>
<?php query_posts(’showposts=5&cat=3′);?
<?php while (have_posts()) : the_post(); ?>
<!–get the custom fields gallery_image
(fields which contains the link to the image to show in the gallery)
–>
<?php $values = get_post_custom_values(”gallery_image”);?>
<!– Verify if you set the custom field gallery_image for the post –>
<?php if(isset($values[0]))
{?>
<!–define a gallery element–>
<div class=”imageElement”>
<!–post’s title to show for this element–>
<h3><?php the_title(); ?></h3>
<!–post’s excerpt to show for this element–>
<?php the_excerpt(); ?>
<!–Link to the full post–>
<a href=”<?php the_permalink() ?>” title=”Read more” class=”open”></a>
<!– Define the image for the gallery –>
<img src=”<?php echo $values[0]; ?>” class=”full” alt=”<?php the_title(); ?>”/>
<!– Define the thumbnail for the gallery –>
<img src=”<?php echo $values[0]; ?>” class=”thumbnail” alt=”<?php the_title(); ?>”/>
</div>
<?php }?>
<?php endwhile; ?>
</div>
</div>
  
?

4. 將gallery放到你的主題中

把<?php include (’gallery.php’); ?>放入你想添加的位置。當你完成這一步時,你的gallery就已經可以工作了。

要使你的gally運轉起來,你需要在新建一個名為 gallery_image的自定義字段,字段值即為需要展示的圖片鏈接,在 wordpress 中推薦用相對地址,比如你的圖片地址為 http://www.yoursite.com/wp-content/uploads/2008/08/artile,只需要填wp-content /uploads/2008/08/artile就可以了。

?

最后一步(不是必須):自定義gallery的具體顯示效果。

?

打開文件wp-content/themes/your_theme_name/css/jd.gallery.css,在這里修改gallery 的寬和高。(通過修改jd.gallery.css完全對這個slideshow根據自己的主題進行個性化。^_^)

?

    #myGallery, #myGallerySet, #flickrGallery
{
width: 590px;
height: 250px;
z-index:5;
border: 1px solid #000;
}
  
?

默認的字號對于中文太小了,可以調整slideshow下方信息欄的高度及文字的字號,只需要修改

?

    .jdGallery .slideInfoZone(滑動信息欄高度、顏色等參數).jdGallery .slideInfoZone h2(信息欄內標題樣式)

.jdGallery .slideInfoZone p(信息欄文本樣式)
  
?

你還可以修改wp-content/themes/your_theme_name/scripts/jd.gallery.js來改變 gallery的展示效果( Smooth Gallery 提供了多種不同的顯示效果,你可以根據需要進行修改)

?

更多定制信息請看 Smooth Gallery Website

?

?

?

?

在wordpress中添加幻燈片展示


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 五月激激激综合网色播免费 | 殴美一级视频 | 亚洲国产精品久久久天堂麻豆 | 中文字幕不卡一区2021 | 四虎国产精品永久地址99新强 | 97色老99久久九九爱精品 | 一级毛片视频免费观看 | 图片亚洲va欧美va国产综合 | 日韩国产欧美在线观看 | 久久亚洲国产精品一区二区 | 中文字幕在线看视频一区二区三区 | 国产在热线精品视频国产一二 | 99热免费精品 | 色综合色狠狠天天综合色 | 女人l8毛片a一级毛片免费 | 日本精品久久久久中文字幕 | 国产一级毛片国语普通话对白 | 四虎网站网址 | 精品伊人久久大香线蕉网站 | 最新四虎4hu影库地址在线 | 偷偷操网站 | 色婷婷久久久swag精品 | 亚洲欧美日本国产综合在线 | 综合色爱 | 久久久亚洲欧洲日产国码二区 | 色婷婷精品大全在线视频 | 国产一区二区精品久久91 | 中文在线日韩 | 国内精品自在自线视频香蕉 | 国产一区二区亚洲精品天堂 | 草莓视频caomei888 | 91精品国产色综合久久不卡蜜 | 老子午夜影院 | 精品久久久久国产免费 | 天天做人人爱夜夜爽2020毛片 | 美女个护士一级毛片亚洲 | 亚洲va国产va欧美va综合 | 一本伊大人香蕉久久网手机 | 中文字幕日本在线观看 | 天天骑夜夜操 | a黄毛片 |