انجمن


قرار دادن کد در حلقه  (۹ نوشته)

  • Mostafa

    آفلاین
    ناظم
    تعداد نوشته‌ها: ۵۲۷۶
    تشکر شده: ۵۷۷۷ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۷ اردیبهشت ۱۳۸۸ - ۲۰:۴۰

    سلام
    میخوام دستور:
    target="_blank"
    و
    title="<?php if(function_exists('the_views')) { the_views(); } ?>"
    را در حلقه:

    <?php } ?>
    
            <?php
    		$postCount = 0;
    		query_posts( 'showposts=&post_per_page=-1&cat=' . get_query_var('cat') );
    		while (have_posts()) { the_post(); 
    
    		if( $postcount == 0 ) { ?>

    قرار بدم :-?
    هرکاری میکنم نمیشه کسی انجامش نمیده ؟

  • Mostafa

    آفلاین
    ناظم
    تعداد نوشته‌ها: ۵۲۷۶
    تشکر شده: ۵۷۷۷ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۸ اردیبهشت ۱۳۸۸ - ۱۱:۵۰

    حلقه بالایی نوشته های یک دسته رو نشون میده
    اینم کد ساده ترش
    <?php the_permalink() ?>" rel="bookmark" target="_blank" title="<?php if(function_exists('the_views')) { the_views(); } ?>"><?php the_title(); ?>
    که میخوام روی حلقه بالایی انجام بدم :-?

  • امین / iishtar

    آفلاین
    عضو
    تعداد نوشته‌ها: ۵۴۲
    تشکر شده: ۴۴ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۸ اردیبهشت ۱۳۸۸ - ۲۱:۰۰

    فکر کنم حلقه رو کامب نذاشتین
    واسه همین کسی جواب نمیده
    البته فکر کنم چون این کدا یه جوریه
    اگه بازم کد بالا پایینش هست بزارین اینجا
    ظاهرا شما ادامه حلقه رو که پایین اینا بوده رو نزاشتین

  • Mostafa

    آفلاین
    ناظم
    تعداد نوشته‌ها: ۵۲۷۶
    تشکر شده: ۵۷۷۷ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۸ اردیبهشت ۱۳۸۸ - ۲۱:۱۳

    اینم حلقه کامل:

    <?php
    		$postCount = 0;
    		query_posts( 'showposts=&post_per_page=-1&cat=' . get_query_var('cat') );
    		while (have_posts()) { the_post(); 
    
    		if( $postcount == 0 ) { ?><?php } elseif( $postcount > 0 && $postcount <= 0 ) { ?><?php } else {
    			ob_start();
    			echo '<li><a href="';
    			the_permalink();
    			echo '">';
    			the_title();
    			echo '</a></li>';
    			$links[] = ob_get_contents();
    			ob_end_clean();
    		}
    		$postcount ++;
    		}
    
    	} else { ?><?php } ?><?php
    //This gets the rest of the archived headlines
    if(count($links)): ?

    :-?

  • امین / iishtar

    آفلاین
    عضو
    تعداد نوشته‌ها: ۵۴۲
    تشکر شده: ۴۴ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۸ اردیبهشت ۱۳۸۸ - ۲۱:۴۴

    اینو امتحان کنید لطفا

    <?php
    		$postCount = 0;
    		query_posts( 'showposts=&post_per_page=-1&cat=' . get_query_var('cat') );
    		while (have_posts()) { the_post(); 
    
    		if( $postcount == 0 ) { ?><?php } elseif( $postcount > 0 && $postcount <= 0 ) { ?><?php } else {
    			ob_start();
    			echo '<li><a href="';
    			the_permalink();
    			echo '" target="_blank" title="';
    			if(function_exists('the_views')) { the_views(); }
    			echo '">';
    			the_title();
    			echo '</a></li>';
    			$links[] = ob_get_contents();
    			ob_end_clean();
    		}
    		$postcount ++;
    		}
    
    	} else { ?><?php } ?><?php
    //This gets the rest of the archived headlines
    if(count($links)): ?
  • Mostafa

    آفلاین
    ناظم
    تعداد نوشته‌ها: ۵۲۷۶
    تشکر شده: ۵۷۷۷ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۸ اردیبهشت ۱۳۸۸ - ۲۳:۵۴

    نه بازم نشد :-?
    Parse error: syntax error, unexpected '?' in F:\Program Files\AppServ\www\wordpress\wp-content\themes\mimboPro\category.php on line 42
    همه راه هارو رفتم انگار داخل حلقه while هیچ چیز وارد نمیشه
    ایشتار جان ممنون از خیرش گذشتیم :|

  • oshgool

    آفلاین
    عضو
    تعداد نوشته‌ها: ۵۹۳
    تشکر شده: ۶۵ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۹ اردیبهشت ۱۳۸۸ - ۰۱:۳۷

    <?php
    		$postCount = 0;
    		query_posts( 'showposts=&post_per_page=-1&cat=' . get_query_var('cat') );
    		while (have_posts()) { the_post(); 
    
    		if( $postcount == 0 ) { ?><?php } elseif( $postcount > 0 && $postcount <= 0 ) { ?><?php } else {
    			ob_start();
    			echo '<li><a target="_blank" href="';
    			the_permalink();
    			echo '">';
    			the_title();
    			echo '</a></li>';
    			$links[] = ob_get_contents();
    			ob_end_clean();
    		}
    		$postcount ++;
    		}
    
    	} else { ?><?php } ?><?php
    //This gets the rest of the archived headlines
    if(count($links)): ?

    اینو تست کن.
    البته این حلقه ای که گذاشتی واسه من که اصلا کار نکرد و ارور میداد. فکرکنم یه تیکه ته کد رو نزاشتی. باز تستش کن اونجا من اضافه کردم target="_balnk" رو.
    اینم جفت دستورهات در حلقه زیر:

    <?php
    		$postCount = 0;
    		query_posts( 'showposts=&post_per_page=-1&cat=' . get_query_var('cat') );
    		while (have_posts()) { the_post(); 
    
    		if( $postcount == 0 ) { ?><?php } elseif( $postcount > 0 && $postcount <= 0 ) { ?><?php } else {
    			ob_start();
    			echo '<li><a target="_blank" title="<?php if(function_exists('the_views')) { the_views(); } ?>" href="';
    			the_permalink();
    			echo '">';
    			the_title();
    			echo '</a></li>';
    			$links[] = ob_get_contents();
    			ob_end_clean();
    		}
    		$postcount ++;
    		}
    
    	} else { ?><?php } ?><?php
    //This gets the rest of the archived headlines
    if(count($links)):
  • Mostafa

    آفلاین
    ناظم
    تعداد نوشته‌ها: ۵۲۷۶
    تشکر شده: ۵۷۷۷ بار
    # نوشته شده: ۱۴ سال پیش
    ۱۹ اردیبهشت ۱۳۸۸ - ۰۱:۴۶

    گفتم که نمیشه!
    Parse error: syntax error, unexpected '?' in F:\Program Files\AppServ\www\wordpress\wp-content\themes\mimboPro\category.php on line 40
    از خیر postview گذشتیم

  • abamahdi313

    آفلاین
    عضو
    تعداد نوشته‌ها: ۲۰
    تشکر شده: ۴ بار
    # نوشته شده: ۱۳ سال پیش
    ۱۹ دی ۱۳۸۹ - ۱۸:۳۱

    با تشکر از بهروزbehroooz
    من اینکار رو انجام دادم اما در صفحه جدیدم مشکل بوجود اومد یکی از مطالب اون دسته رو بارها پشت سر هم تکرار کرد
    ممکنه مشکل از حلقم باشه
    این حلقه منه
    تو سایر صفحات سینگل و ایندکس مشکلی نداره
    <?php query_posts('cat=5'); ?>
    <div id="post-<?php the_ID(); ?>">
    <div class="txt"><?php the_content('
    ادامه مطلب'); ?></div>
    <p class="meta">در دسته : <?php the_category(' ، ') ?> |
    <?php comments_popup_link('0 دیدگاه', '1 دیدگاه', '% دیدگاه'); ?></p>
    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>

    جمله اول همون دستوریه که اوردم
    باتشکر منتظر جوابتون
    صفحه ایی که مشکل داره
    http://www.abamahdi.com/?page_id=360
    باتشکر

    http://www.abamahdi.com
    abamahdi313@gmail.com

    ویرایش

درباره‌ی این موضوع



برچسب‌ها