comment_approved ) : ?>
is_home() && $query->is_main_query() ) {
$query->set( 'cat', '1' );
}
}
add_action( 'pre_get_posts', 'custom_category_on_homepage' );
function get_alhana_archive($show_comment_count=0, $show_cat_slug='bez-rubriki', $year=0, $post_type='post', $limit=100){
global $month, $wpdb;
$result = '';
if($year) $AND_year = " AND YEAR(post_date)='$year'";
if($limit) $LIMIT = " LIMIT $limit";
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_type='$post_type' AND post_status='publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
if($arcresults){
foreach($arcresults as $arcresult) {
$text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
$result .= '
'.$text.'
';
$thismonth = zeroise($arcresult->month,2);
$thisyear = $arcresult->year;
$arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status, guid, comment_count FROM " . $wpdb->posts . " WHERE post_date LIKE '$thisyear-$thismonth-%' AND post_status='publish' AND post_type='$post_type' AND post_password='' ORDER BY post_date DESC $LIMIT");
if ($arcresults2){
$result .= "
\n";
foreach ($arcresults2 as $arcresult2) {
$checkcat = get_the_category( $arcresult2->ID );
if (!empty($checkcat) && ($checkcat[0]->category_nicename == $show_cat_slug)) { if ($arcresult2->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult2->ID);
$arc_title = $arcresult2->post_title;
if ($arc_title) $text = strip_tags($arc_title);
else $text = $arcresult2->ID;
if($show_comment_count){
$cc = $arcresult2->comment_count;
if ($arcresult2->comment_status == "open" OR $comments_count > 0) $text .= " | $cc";
}
$result .= "