jaboli
جمعه 14 آذر 1393, 09:37 صبح
سلام من یه tab content ساختم که با ajax کار میکنه به طوری که فقط تبی که روش کلیک میشه محتواشو نشون بده و این کار باعث افزایش سرعت سایت میشه
ولی مشکلی که داره اینه که فقط محتوای تب اول رو نشون میده
http://bourstahlil.ir/ (ستون سمت چپ)
کد هاشم ایناهاست
کد برگه ای که فراخوانی میشه محتوا :
<?php/*template name: left ajax*/if(isset($_REQUEST['tab'])) :$tab = $_REQUEST['tab'];if($tab==4) { ?><div id="tab4" class="tabs-wrap"><?php$custom_query = new WP_Query(array('post_status' =>'published','post_type' =>'post','order' =>'descending','orderby' =>'ID','cat' =>'854','posts_per_page' =>'7','paged' => (get_query_var('paged')) ? get_query_var('paged') : 1));?><ul><?php if($custom_query->have_posts()) :while($custom_query->have_posts()) : $custom_query->the_post();?><li><div class="post-thumbnail"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php echo get_the_post_thumbnail(); ?><span class="overlay-icon"></span></a></div><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3><span class="date"><span class="tie-date"><?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) echo timeago(); else echo " " . $days . " روز پیش";?></span></span><br/></li><?php endwhile;endif; ?></ul><?php wp_reset_query(); ?></div><?php}elseif($tab==3) {?><div id="tab3" class="tabs-wrap"><?php$number=7; // number of recent comments desired$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");?><ul id="recentcomments"><?phpif ( $comments ) : foreach ( (array) $comments as $comment) :echo '<li class="recentcomments" style="font-size:11px;">' . sprintf(__('%1$s در %2$s'), get_comment_author_link(), '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';endforeach; endif;?></ul></div><?php}elseif($tab==2) {?><div id="tab2" class="tabs-wrap"><ul><?phpquery_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&showposts=7');if (have_posts()) : while (have_posts()) : the_post(); ?><li><div class="post-thumbnail"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php echo get_the_post_thumbnail(); ?><span class="overlay-icon"></span></a></div><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3><span class="date"><span class="tie-date"><?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) echo timeago(); else echo " " . $days . " روز پیش";?></span><br/></span></li><?phpendwhile; endif;wp_reset_query();?></ul></div><?php}else {?><div id="tab1" class="tabs-wrap"><?php$custom_query1 = new WP_Query(array('post_status' =>'published','post_type' =>'post','order' =>'descending','orderby' =>'ID','cat' =>'894,893,10,851,853,14,855,13,856,857,859,15','pos ts_per_page' =>'8','paged' => (get_query_var('paged')) ? get_query_var('paged') : 1));?><ul><?php if($custom_query1->have_posts()) :while($custom_query1->have_posts()) : $custom_query1->the_post();?><li><div class="post-thumbnail"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"> <?php echo get_the_post_thumbnail(); ?> <span class="overlay-icon"></span></a></div><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3><span class="date"><span class="tie-date"><?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) echo timeago(); else echo " " . $days . " روز پیش";?></span><br/></span></li><?php endwhile;endif; ?></ul><?php wp_reset_query(); ?></div><?php}endif; ?>
کدی که توی سایت قرار دادم
<script type="text/javascript">$(document).ready(function() {$("#tab-entry").load('http://bourstahlil.ir/ajax',{tab:1}); $("#tab-entry").promise().done(function() { $("#loading").hide("normal").prev("#tab-entry").delay(1000).show("normal"); });$(".tab-button").click(function() { var tab = $(this).attr("data-tab"); var dl = $("#tab-entry").attr("data-load"); if(tab !== dl) { $(this).parent("li").parent("ul").find(".active").removeClass("active"); $(this).addClass("active"); $("#tab-entry").each(function() { $(this).attr("data-load", tab).hide('normal').load('http://bourstahlil.ir/ajax',{tab:tab}).next("#loading").delay(500).show(); }); $("#tab-entry").promise().done(function() { $("#loading").delay(500).hide("normal").prev("#tab-entry").delay(1000).show("normal"); }); }});});</script><aside class="sidebar" style="margin-bottom:-12px"><div class="widget" id="tabbed-widget"><div style="margin-top:-20px" class="widget-container"><div class="widget-top"><!-- نوار کلیدهای تب --><ul class="tabs posts-taps"><li class="tabs"> <a class="tab-button active" data-tab="1">تب اول </a></li><li class="tabs"> <a class="tab-button" data-tab="2">تب دوم </a></li><li class="tabs"> <a class="tab-button" data-tab="3">تب سوم </a></li><li class="tabs"> <a class="tab-button" data-tab="4">تب چهارم </a></li></ul><!-- / نوار کلیدهای تب --><div class="tab-content"><div id="tab-entry" style="display:none" data-load="1"><?phpquery_posts( array( 'page_id' => 36848 ) ); // ID of the page including the formif ( have_posts() ) : while ( have_posts() ) : the_post(); the_content();endwhile; endif;wp_reset_query();?></div><div id="loading">Load ... </div></div></div></div></aside>
ممنون میشم کسی بتونه کمکی بکنه
ولی مشکلی که داره اینه که فقط محتوای تب اول رو نشون میده
http://bourstahlil.ir/ (ستون سمت چپ)
کد هاشم ایناهاست
کد برگه ای که فراخوانی میشه محتوا :
<?php/*template name: left ajax*/if(isset($_REQUEST['tab'])) :$tab = $_REQUEST['tab'];if($tab==4) { ?><div id="tab4" class="tabs-wrap"><?php$custom_query = new WP_Query(array('post_status' =>'published','post_type' =>'post','order' =>'descending','orderby' =>'ID','cat' =>'854','posts_per_page' =>'7','paged' => (get_query_var('paged')) ? get_query_var('paged') : 1));?><ul><?php if($custom_query->have_posts()) :while($custom_query->have_posts()) : $custom_query->the_post();?><li><div class="post-thumbnail"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php echo get_the_post_thumbnail(); ?><span class="overlay-icon"></span></a></div><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3><span class="date"><span class="tie-date"><?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) echo timeago(); else echo " " . $days . " روز پیش";?></span></span><br/></li><?php endwhile;endif; ?></ul><?php wp_reset_query(); ?></div><?php}elseif($tab==3) {?><div id="tab3" class="tabs-wrap"><?php$number=7; // number of recent comments desired$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");?><ul id="recentcomments"><?phpif ( $comments ) : foreach ( (array) $comments as $comment) :echo '<li class="recentcomments" style="font-size:11px;">' . sprintf(__('%1$s در %2$s'), get_comment_author_link(), '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';endforeach; endif;?></ul></div><?php}elseif($tab==2) {?><div id="tab2" class="tabs-wrap"><ul><?phpquery_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&showposts=7');if (have_posts()) : while (have_posts()) : the_post(); ?><li><div class="post-thumbnail"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php echo get_the_post_thumbnail(); ?><span class="overlay-icon"></span></a></div><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3><span class="date"><span class="tie-date"><?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) echo timeago(); else echo " " . $days . " روز پیش";?></span><br/></span></li><?phpendwhile; endif;wp_reset_query();?></ul></div><?php}else {?><div id="tab1" class="tabs-wrap"><?php$custom_query1 = new WP_Query(array('post_status' =>'published','post_type' =>'post','order' =>'descending','orderby' =>'ID','cat' =>'894,893,10,851,853,14,855,13,856,857,859,15','pos ts_per_page' =>'8','paged' => (get_query_var('paged')) ? get_query_var('paged') : 1));?><ul><?php if($custom_query1->have_posts()) :while($custom_query1->have_posts()) : $custom_query1->the_post();?><li><div class="post-thumbnail"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"> <?php echo get_the_post_thumbnail(); ?> <span class="overlay-icon"></span></a></div><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3><span class="date"><span class="tie-date"><?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) echo timeago(); else echo " " . $days . " روز پیش";?></span><br/></span></li><?php endwhile;endif; ?></ul><?php wp_reset_query(); ?></div><?php}endif; ?>
کدی که توی سایت قرار دادم
<script type="text/javascript">$(document).ready(function() {$("#tab-entry").load('http://bourstahlil.ir/ajax',{tab:1}); $("#tab-entry").promise().done(function() { $("#loading").hide("normal").prev("#tab-entry").delay(1000).show("normal"); });$(".tab-button").click(function() { var tab = $(this).attr("data-tab"); var dl = $("#tab-entry").attr("data-load"); if(tab !== dl) { $(this).parent("li").parent("ul").find(".active").removeClass("active"); $(this).addClass("active"); $("#tab-entry").each(function() { $(this).attr("data-load", tab).hide('normal').load('http://bourstahlil.ir/ajax',{tab:tab}).next("#loading").delay(500).show(); }); $("#tab-entry").promise().done(function() { $("#loading").delay(500).hide("normal").prev("#tab-entry").delay(1000).show("normal"); }); }});});</script><aside class="sidebar" style="margin-bottom:-12px"><div class="widget" id="tabbed-widget"><div style="margin-top:-20px" class="widget-container"><div class="widget-top"><!-- نوار کلیدهای تب --><ul class="tabs posts-taps"><li class="tabs"> <a class="tab-button active" data-tab="1">تب اول </a></li><li class="tabs"> <a class="tab-button" data-tab="2">تب دوم </a></li><li class="tabs"> <a class="tab-button" data-tab="3">تب سوم </a></li><li class="tabs"> <a class="tab-button" data-tab="4">تب چهارم </a></li></ul><!-- / نوار کلیدهای تب --><div class="tab-content"><div id="tab-entry" style="display:none" data-load="1"><?phpquery_posts( array( 'page_id' => 36848 ) ); // ID of the page including the formif ( have_posts() ) : while ( have_posts() ) : the_post(); the_content();endwhile; endif;wp_reset_query();?></div><div id="loading">Load ... </div></div></div></div></aside>
ممنون میشم کسی بتونه کمکی بکنه