<?php get_header(); ?>
<div id="main-head">
<table cellpadding="0" border="0" cellspacing="0">
<tr>
<td width="239" valign="middle" class="main-head-1">
<div class="main-head-text1">
Главное
</div></td>
<td valign="middle" height="23"><img src="images/head_title2.jpg" alt="" width="19" height="23" hspace="0"></td>
<td valign="middle" class="main-head-3">
<div class="main-head-text2">
</div></td>
</tr>
</table>
</div>
<?php
query_posts(
array(
'cat' => 15,
'post__in' => get_option('sticky_posts'),
)
);
home_main_posts();
//based on Austin Matzko's code from wp-hackers email list
function filter_where($where = '') {
//posts in the last 1 day
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-1 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts(
array(
'post_type' => 'post',
'post__not_in' => get_option('sticky_posts'),
'cat' => 15,
'orderby' => 'date',
'order' => 'DESC',
)
);
//query_posts('post_type=post&cat=15&caller_get_posts=1&orderby=date&order=DESC');
if (have_posts()) :
home_main_posts();
wp_reset_query();
remove_filter('posts_where', 'filter_where');
else :
$lastpost = get_posts('category=15&numberposts=1&orderby=date&order=DESC');
$lastpost_date = strtotime($lastpost[0]->post_date);
function filter_where2($where = '') {
global $lastpost_date;
//posts in the last 1 day from the last post
$where .= " AND post_date > '" . date('Y-m-d', $lastpost_date-24*3600) . "'";
return $where;
}
//make query for vacanties days
remove_filter('posts_where', 'filter_where');
add_filter('posts_where', 'filter_where2');
wp_reset_query();
query_posts(
array(
'post_type' => 'post',
'post__not_in' => get_option('sticky_posts'),
'cat' => 15,
'orderby' => 'date',
'order' => 'DESC',
)
);
home_main_posts();
wp_reset_query();
remove_filter('posts_where', 'filter_where2');
endif;
// query_posts('cat=15&nopaging=true&orderby=date&order=DESC');
// $postslist = get_posts('category_name=main&orderby=date&order=DESC');
// $postslist = get_posts('category_name=main & order=ASC & meta_key=rating & orderby=meta_value');
// foreach ($postslist as $post) :
// setup_postdata($post);
/*function review_tie_breaker_stick($a, $b) {
// get the priority value for each
$a_priority = is_sticky($a->ID)?20:0;
$b_priority = is_sticky($b->ID)?20:0;
// if a priority value has not been entered, default to 0
$a_priority = ($a_priority == '') ? 0 : (int)$a_priority;
$b_priority = ($b_priority == '') ? 0 : (int)$b_priority;
// if the priority is also equal, just return as a tie
if ($a_priority == $b_priority) {
return 0;
}
// if not, we return the priority comparison
return ($a_priority > $b_priority) ? -1 : 1;
}
usort($postslist, 'review_tie_breaker_stick');*/
function home_main_posts() {
if (have_posts()) :
while (have_posts()) : the_post();
?>
<table class="news_item" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="images/news_1.jpg" width="25" height="23" alt=""></td>
<td>
<div id="news-date">
<?php the_time('d.m.Y'); ?>
</div>
</td>
<td>
<img src="images/news_2.jpg" width="12" height="23" alt=""></td>
<td id="news-time">
<?php the_time(); ?>
</td>
<td>
<img src="images/news_3.jpg" width="11" height="23" alt=""></td>
</tr>
</table>
</td>
<td width="100%" id="main-news-title" valign="middle">
<a href="<?php the_permalink();?>"><?php the_title();?></a>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<div id="main-news-body">
<div style="float:left"><?php the_post_thumbnail('thumbnail');?></div> <?php the_excerpt(); ?>
</div></td>
</tr>
</table>
<?php //endforeach; ?>
<?php endwhile; ?>
<?php endif; }?>
<div id="main-head" align="right">
<table cellpadding="0" cellspacing="0" >
<tr>
<td id="main-news-all1"><img src="images/main_news_all1.jpg" width="19" height="18" alt=""></td>
<td id="main-news-all-text" valign="middle"><a href="index.php?cat=15">все главные новости>></a></td>
<td id="main-news-all2"><img src="images/main_news_all2.jpg" width="8" height="18" alt=""></td>
</tr>
</table>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>