رفتن به مطلب

نمایش تصادفی مطالب از دسته خاص


پست های پیشنهاد شده

سلام

توی نت زیاد سرچ کردم و به کد orderby=rand رسیدم ولی مشکلم اینه که مطالب قالبم با کد خاصی لود میشه. هرچی سعی کردم نتونستم از این خاصیت استفاده کنم. کد زیر مال بخش مربوط به قالب هست:


<?php if (arras_get_option('enable_news')) : ?>
<?php arras_above_index_news_post() ?> <!-- News Articles -->
<div id="index-news">
<?php if (arras_get_option('news_title') != '') : ?>
<div class="home-title"><?php _e(arras_get_option('news_title')) ?></div>
<?php endif; ?>
<?php
$news_query_args = apply_filters('arras_news_query', array('list' => $news_cat, 'taxonomy' => arras_get_option('news_tax'), 'query' => array('posts_per_page' => arras_get_option('index_count'), 'exclude' => $post_blacklist, 'post_type' => arras_get_option('news_posttype'), 'paged' => $paged)));
$news_query = arras_prep_query($news_query_args);
query_posts($news_query);
?>
</div><!-- #index-news -->
<?php arras_below_index_news_post() ?>
<?php endif; ?>

حتی این کد هم زدم ولی نشد: query_posts($news_query . 'orderby = rand');

ویرایش شده توسط poriia
لینک به ارسال

سلام

توی نت زیاد سرچ کردم و به کد orderby=rand رسیدم ولی مشکلم اینه که مطالب قالبم با کد خاصی لود میشه. هرچی سعی کردم نتونستم از این خاصیت استفاده کنم. کد زیر مال بخش مربوط به قالب هست:


<?php if (arras_get_option('enable_news')) : ?>
<?php arras_above_index_news_post() ?> <!-- News Articles -->
<div id="index-news">
<?php if (arras_get_option('news_title') != '') : ?>
<div class="home-title"><?php _e(arras_get_option('news_title')) ?></div>
<?php endif; ?>
<?php
$news_query_args = apply_filters('arras_news_query', array('list' => $news_cat, 'taxonomy' => arras_get_option('news_tax'), 'query' => array('posts_per_page' => arras_get_option('index_count'), 'exclude' => $post_blacklist, 'post_type' => arras_get_option('news_posttype'), 'paged' => $paged)));
$news_query = arras_prep_query($news_query_args);
query_posts($news_query);
?>
</div><!-- #index-news -->
<?php arras_below_index_news_post() ?>
<?php endif; ?>

حتی این کد هم زدم ولی نشد: query_posts($news_query . 'orderby = rand');


<?php if (arras_get_option('enable_news')) : ?>
<?php arras_above_index_news_post() ?> <!-- News Articles -->
<div id="index-news">
<?php if (arras_get_option('news_title') != '') : ?>
<div class="home-title"><?php _e(arras_get_option('news_title')) ?></div>
<?php endif; ?>
<?php
$news_query_args = apply_filters('arras_news_query', array('list' => $news_cat, 'taxonomy' => arras_get_option('news_tax'), 'query' => array('posts_per_page' => arras_get_option('index_count'), 'exclude' => $post_blacklist, 'post_type' => arras_get_option('news_posttype'), 'paged' => $paged,orderby=>'rand')));
$news_query = arras_prep_query($news_query_args);
query_posts($news_query);
?>
</div><!-- #index-news -->
<?php arras_below_index_news_post() ?>
<?php endif; ?>

لینک به ارسال

درست شد، آرگومان باید به صورت زیر باشه:


'orderby' => 'rand'

بستگی داره شکل های مختلفی داره که در کوئری شما اینگونه بود

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...