自定義hotnews幻燈及頂部熱點(diǎn)圖片鏈接

字號(hào):


    有童鞋在faq.wopus.org問(wèn):幻燈片及熱點(diǎn)文章圖片鏈接如何設(shè)置成可以指向別人網(wǎng)站的外鏈?這個(gè)功能貌似之前幫人diy過(guò),適合作外鏈廣告或者鏈接到其它站點(diǎn),可以內(nèi)鏈接也可外鏈,方便靈活,操作也不是很復(fù)雜,發(fā)出來(lái)為有此需求者提供參考。
    首頁(yè)幻燈
    打開hotnewsproincludes目錄的slider.php模板文件,查找:
    <?php if ( get_post_meta($post->id, 'show', true) ) : ?>
    <?php $image = get_post_meta($post->id, 'show', true); ?>
    <a href=<?php the_permalink() ?> rel=bookmark title=<?php the_title(); ?>><img src=<?php echo $image; ?>width=400 height=248 alt=<?php the_title(); ?>/></a>
    <?php else: ?>
    替換為:
    <?php if ( get_post_meta($post->id, 'show', true) ) : ?>
    <?php $image = get_post_meta($post->id, 'show', true); ?>
    <?php $url = get_post_meta($post->id, 'imgurl', true); ?>
    <a href=<?php echo $url; ?> rel=bookmark title=<?php the_title(); ?>><img src=<?php echo $image; ?>width=400 height=248 alt=<?php the_title(); ?>/></a>
    <?php else: ?>
    使用該功能必須使用自定義欄目:
    show 調(diào)用圖片
    imgurl 圖片鏈接到的url地址
    頂部熱點(diǎn)圖片
    打開hotnewsproincludes目錄的top_hot_a.php模板文件,用下代碼替換所有:
    <div id=featured class=clearfix>
    <?php $recent = new wp_query('meta_key=hot&orderby=rand&showposts=4&caller_get_posts=4'); while($recent->have_posts()) : $recent->the_post();?>
    <div class=item>
    <div class=top_t>
    <?php $image = get_post_meta($post->id, 'image', true); ?>
    <?php $url = get_post_meta($post->id, 'imgurl', true); ?>
    <a href=<?php the_permalink() ?> rel=bookmark title=<?php the_title(); ?>><img src=<?php echo $image; ?> alt=<?php the_title(); ?>/></a>
    </div>
    <div class=top_box><a href=<?php echo $url; ?> rel=bookmark title=<?php the_title_attribute(); ?>>詳細(xì)內(nèi)容</a></div>
    <div class=boxcaption>
    <h2><a href=<?php echo $url; ?> title=permalink to <?php the_title(); ?>><?php echo cut_str($post->post_title,30); ?></a></h2>
    </div>
    </div>
    <?php endwhile; ?>
    <div class=clear></div>
    </div>
    使用方法同樣需要使用自定義欄目:
    hot 調(diào)用文章
    image 調(diào)用圖片
    imgurl 圖片鏈接到的url地址