Hi imon,
How do you want to change what’s displayed?
Do you want a certain number of posts, posts only from one category, posts with a certain tag…?
Thanks
VW
no i am not changing any thing .
when i add the code then i have too many post displayed- duplicated posts.
for example if i have 12 post . when i add this code it displayed 24 post .
thanks
Understood, can you post the entire code of the file containing the query_posts as described above?
The question really is where are you putting it and as VaderW asked, what is the code. If more than 10 lines use a gist, or pastebin. 🙂
this is my code
<?php if(of_get_option('frontcat_checkbox') == "1"){ ?>
<?php if(is_front_page()) {
$args = array(
'cat' => ''.$os_front = of_get_option('front_cat').'',
'post_type' => 'post',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
'posts_per_page' => ''.$os_fonts = of_get_option('frontnum_select').'');
query_posts($args);
} ?>
<?php }?>
<?php query_posts('orderby=rand'); ?>
<?php
if(have_posts()): ?><?php while(have_posts()): ?><?php the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
Looks like when the if statements are true, you query_posts twice, duplicating the posts. To get around this move the orderby=rand into the $args array, adjust the second query_posts() to use this array in it’s query, and remove the first query_posts() completely.
So try…
<?php if(of_get_option('frontcat_checkbox') == "1"){ ?>
<?php if(is_front_page()) {
// This sets the values of $args if the above both return true
$args = array(
'cat' => ''.$os_front = of_get_option('front_cat').'',
'post_type' => 'post',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
'posts_per_page' => ''.$os_fonts = of_get_option('frontnum_select').'',
'orderby' => 'rand');
} ?>
<?php }?>
<?php
// query_posts() occurs once, returning one set of posts matching the values of $args
query_posts($args); ?>
<?php
if(have_posts()):
// If we have the posts, display them ?>
<?php while(have_posts()): ?>
<?php the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
thanks
but its not working result is same