yollyflopp
Member
Posted 1 year ago #
I'm using this script for making just one of my categories show on each day of the week;
<?php global $query_string;
query_posts( $query_string . "&order=ASC" ); ?>
<?php $today = date('N');
if( $today == 1 ) : query_posts( 'cat=6' ); { ?>
<?php } elseif( $today == 2 ) : query_posts( 'cat=5' ); { ?>
<?php } elseif( $today == 3 ) : query_posts( 'cat=7' ); { ?>
<?php } elseif( $today == 4 ) : query_posts( 'cat=9' ); { ?>
<?php } elseif( $today == 5 ) : query_posts( 'cat=10' ); { ?>
<?php } elseif( $today == 6 ) : query_posts( 'cat=8' ); { ?>
<?php } elseif( $today == 7 ) : query_posts( 'cat=11' ); { ?>
<?php } ?>
<?php endif; ?>
I show 1 post/page, the count of posts is right, so if the category has 5 posts I can see 5 pages, but with the same post on every page, can someone please help me with this?
Try:
<?php
$today = date('N') ;
if( $today == 1 ) $my_cat = '&cat=6';
elseif( $today == 2 ) $my_cat = '&cat=5';
elseif( $today == 3 ) $my_cat = '&cat=7';
elseif( $today == 4 ) $my_cat = '&cat=9';
elseif( $today == 5 ) $my_cat = '&cat=10';
elseif( $today == 6 ) $my_cat = '&cat=8';
elseif( $today == 7 ) $my_cat = '&cat=11';
else $my_cat = '';
query_posts( $query_string . $my_cat . '&order=ASC' ) ;'
?>
yollyflopp
Member
Posted 1 year ago #
Hmm sorry but the site isn't showing at all with that, any other ideas or can you see someting wrong with it?
JV Custom Designs
Member
Posted 1 year ago #
With your original code, are the posts shown in the categories? If so, add this above your global $query_string but within the php code:
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
And change: query_posts( $query_string . "&order=ASC" );
to: query_posts( $query_string . "&order=ASC&paged=$paged" );
yollyflopp
Member
Posted 1 year ago #
It still doesn't work in index see this page, it's the same problem as the whole time, it shows 5 posts (in 5 pages) but the post is the same on every page.
<?php if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
global $query_string;
query_posts( $query_string . "&order=ASC&paged=$paged" ); ?>
<?php $today = date('N');
if( $today == 1) : query_posts( 'cat=10' ); { ?>
<?php } elseif( $today == 2 ) : query_posts( 'cat=5' ); { ?>
<?php } elseif( $today == 3 ) : query_posts( 'cat=7' ); { ?>
<?php } elseif( $today == 4 ) : query_posts( 'cat=9' ); { ?>
<?php } elseif( $today == 5 ) : query_posts( 'cat=6' ); { ?>
<?php } elseif( $today == 6 ) : query_posts( 'cat=11' ); { ?>
<?php } elseif( $today == 7 ) : query_posts( 'cat=8' ); { ?>
<?php } ?>
<?php endif; ?>
with your conditional query_posts, you are overwriting the first query_posts code;
try in each of these lines to replace:
if( $today == 1) : query_posts( 'cat=10' );
with:
if( $today == 1) : query_posts( $query_string . "&order=ASC&paged=$paged&cat=10" );
yollyflopp
Member
Posted 1 year ago #
OH thanks, that made my day! Now its working, but i had to change the ASC to DSC, so I got the latest first. I changed this to resolved. Thanks again!