GoodNightJournal
Member
Posted 4 months ago #
Below code that I added before loop in archive.php doesn't work. However, it works without '&day='.$day. code that I added for viewing posts by day. I have no idea what is wrong with this code. can anyone tell me what to fix? thanks in advance.
<?php
wp_get_current_user();
$loggedin_user_name = $current_user->user_login;
$year = get_the_time('Y');
$month = get_the_time('m');
$day = get_the_time('d');
query_posts('year='.$year.'&monthnum='.$month.'&day='.$day.'cat=2&posts_per_page='.get_option('posts_per_page').'&author_name='.$loggedin_user_name);
?>
GoodNightJournal
Member
Posted 4 months ago #
above code displays everything correctly. however, when I click on days in WP default calendar, it does not retrieve posts on the day I clicked.
Plz help!
GoodNightJournal
Member
Posted 4 months ago #
Apparently fixing code to below solved my problem. lol
<?php
wp_get_current_user();
$loggedin_user_name = $current_user->user_login;
$year = get_the_time('Y');
$month = get_the_time('m');
$day = get_the_time('d');
if ( is_day() ) :
query_posts('day='.$day.'cat=2&posts_per_page='.get_option('posts_per_page').'&author_name='.$loggedin_user_name);
elseif ( is_month() ) :
query_posts('&monthnum='.$month.'cat=2&posts_per_page='.get_option('posts_per_page').'&author_name='.$loggedin_user_name);
elseif ( is_year() ) :
query_posts('year='.$year.'cat=2&posts_per_page='.get_option('posts_per_page').'&author_name='.$loggedin_user_name);
else :
_e( 'Archives', 'twentytwelve' );
endif;
?>