2013-05-30 34 views
0

這裏是我的模板中的index.php文件。懶加載不符合我的自定義分頁

<?php get_header(); ?> 

    <div id="content"> 
    <div id="content_inside"> 

<?php 
    wp_reset_query(); 
    $get_blog_id = '-' . get_category_id('blog'); 

    if(get_category_id('blog') != '') { 
     $args = array(
      'post_type' => 'post', 
      'cat' => $get_blog_id, 
      'posts_per_page' => 6, 
      'paged' => (get_query_var('paged') ? get_query_var('paged') : 1) 
     );   
     } else { 
    $args = array(
     'post_type' => 'post', 
     'posts_per_page' => 6, 
     'paged' => (get_query_var('paged') ? get_query_var('paged') : 1) 
    ); 
     } 
query_posts($args); 
    $x = 0; 
     while (have_posts()) : the_post(); ?> 

<?php if($x % 2 == 0) { ?> 

    <div class="post_box"> 

<?php } else { ?> 
    <div class="post_box post_box_right"> 
<?php } ?> 

<?php if ($x == 0) { ?> 
    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> 
<?php } elseif ($x == 1 || $x == 2 || $x == 3) { ?> 
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
<?php } elseif ($x == 4 || $x == 5) { ?> 
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
<?php } else { ?> 
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
<?php } ?> 

    <div class="post_meta"><?php the_author(); ?>/<?php the_time('d m , Y') ?> - <?php the_time('H:i'); ?>/<?php comments_popup_link('Yorum Yok', '1 Yorum', '% Yorum'); ?></div> 

    <div class="img_link"> 
    <a href="<?php the_permalink(); ?>"> 
<?php the_post_thumbnail('featured-home'); ?> 
<?php 
//$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'featured-home');$url = $thumb['0']; 
//$titleGet = get_the_title($post->ID); 
//echo '<img src="'.CDN.'/assets/images/_load.png" alt="'.$titleGet.'" data-modafesto="'.$url.'" width="301" height="398" />'; 
?> 
    </a> 
    </div> 
<div class="post_cat"> 

<?php 
    $category = get_the_category(); 
    echo '<a href="'.get_category_link($category[0]->cat_ID).'" title="'.$category[0]->cat_name.' ile alakalı tüm modafestoları göster">'.$category[0]->cat_name.'</a>'; 
?> konu başlığı ile yayınlandı. 
    </div> 

</div><!--//post_box-->   

<?php if($x % 2 == 1) { ?> 
    <div class="clear"></div> 
<?php } ?> 

<?php $x++; ?> 
<?php endwhile; ?> 

    <div class="clear"></div> 

</div><!--//content_inside--> 
<div class="clear"></div> 
<div class="load_more_cont"> 
<div style="margin:0px auto;"><div class="load_more_text"><?php next_posts_link('DİĞER YAZILARI YÜKLE') ?></div></div> 
    </div><!--//load_more_cont-->     

<?php wp_reset_query(); ?>              

    </div><!--//content--> 

<script type="text/javascript">$(".load_more_cont a").live("click",function(a){a.preventDefault();$(".load_more_text a").html("Yazılar Yükleniyor...");$.ajax({type:"GET",url:$(this).attr("href")+"#content",dataType:"html",success:function(b){result=$(b).find("#content_inside .post_box");nextlink=$(b).find(".load_more_cont a").attr("href");$("#content_inside").append(result);$(".load_more_text a").html("Daha fazla yazı yükle");if(nextlink!=undefined){$(".load_more_cont a").attr("href",nextlink)}else{$(".load_more_cont").remove();$("#content_inside").append('<div class="clear"></div>')}}})});</script>   

<?php get_sidebar(); ?>   

<?php get_footer(); ?> 

我試過對我的圖像使用惰性加載腳本。因爲它是SEO引擎的絕佳選擇。那行,

<div class="img_link"> 
<a href="<?php the_permalink(); ?>"> 

<?php 
    $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'featured-home');$url = $thumb['0']; 
    $titleGet = get_the_title($post->ID); 
    echo '<img src="'.CDN.'/assets/images/_load.png" alt="'.$titleGet.'" data-modafesto="'.$url.'" width="301" height="398" />'; 
?> 
</a> 
    </div> 

而且,這裏是我的預加載腳本http://j.mp/12QkkTW

當你加載頁面時,第一篇文章是lazyload/preload的核心內容,但是如果你點擊加載更多文章按鈕,當你得到更多文章時,preloader不起作用。

任何人都可以幫助我嗎?謝謝。

+0

你有沒有加入'任何版本jQuery在你的頁面中使用之前?如果有錯誤,請檢查'console'。 –

+0

如果你點擊加載更多文章按鈕,你看到了什麼? –

+0

@RohanKumar其1.8.3 .joe我只看到空白image.Please檢查現場演示:http://j.mp/18wPNkh –

回答

1

嘗試添加

$("XXXXXXX img").lazyload(); 

在阿賈克斯成功回調funcion,追加HTML後,

XXXXX是追加的HTML DOM,EQ:類名或ID

+0

有沒有錯誤。請在這裏查看。 http://j.mp/18wPNkh點擊「DİĞERYAZILARIYÜKLE」鏈接,內容列表的底部。 –

+0

我已經做了。謝謝。 ;) –