Помогите решить дилемму начинающего WordPressera (раньше вобще не кодил). Решил написать собственную тему, максимально отвечающую моим запросом по внешнему функционалу. И так, задача была создать главную страницу разделенную на две части в шапке выводятся последние несколько тем из основной рубрики. Во второй части выводятся все статьи, исключая выведенную выше рубрику и прикрепленные статьи. На странице рубрики сверху выводятся закрепленные записи и дальше все остальные, и исключая уже выведенные.
В итоге выходит что то в таком духе:
[Первый блок(понефрен html код, интересует только php)]
if(is_home())
{
$args = array('numberposts'=>0,'category'=>3);
$lastposts = get_posts( $args );
$n=3;
foreach($lastposts as $post) : setup_postdata($post);
if($n==0) : break; endif
<div id="post">
<div id="post_title" class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div id="post_img"><?php the_post_thumbnail( 'mini_img' ); ?></div>
<div id="post_text"><?php the_excerpt(); ?></div>
<div id="post_battom">Автор: <?php the_author(); ?> Дата публикации: <?php echo get_the_date(); ?></div>
</div>
$n-=1;?>
endforeach;
wp_reset_postdata();
}
Второй блок
if(is_home())
{
query_posts( array( 'cat' => -3, 'paged' => get_query_var('paged'), 'ignore_sticky_posts'=>1 ) );
}
else
{
if ( $paged < 2 )
{
if ( is_category() ) :
parse_str($query_string, $args);
$args['post__in']=get_option('sticky_posts' );
query_posts($args);
if ( have_posts() ) : while ( have_posts() ) : the_post();
<div id="post">
<div id="post_title"><?php the_category(','); ?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div id="post_img"><?php the_post_thumbnail( 'mini_img' ); ?></div>
<div id="post_text"><?php the_excerpt(); ?></div>
<div id="post_battom">Автор: <?php the_author(); ?> Дата публикации: <?php echo get_the_date(); ?></div>
</div>
endwhile;
endif;
endif; ?>
}
wp_reset_query();
$args=array('paged' => get_query_var('paged'), 'post__not_in' =>get_option('sticky_posts' ) );
parse_str($query_string, $args);
$args['post__not_in']=get_option('sticky_posts' );
query_posts($args); }
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="post">
<div id="post_title"><?php the_category(','); ?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div id="post_img"><?php the_post_thumbnail( 'mini_img' ); ?></div>
<div id="post_text"><?php the_excerpt(); ?></div>
<div id="post_battom">Автор: <?php the_author(); ?> Дата публикации: <?php echo get_the_date(); ?></div>
</div>
endwhile;
<div id="end"><?php SEO_pager()?></div>
<?php endif; ?>
wp_reset_query();
}
Так вот выходит не смертное количество циклов, перемудрил… Может можно задачу прикрепления решить попроще? Все работает, но я боюсь, что нагрузка будет через чур большой, даже для такого криворуки как я. А ведь еще сверху нужно добавить один цикл, выводящий случайные записи, еще увеличиться нагрузка…
P.S.: Пока черновой вариант, переписку всего покрасивей и правельней начну когда буду уверен, что основа работает правильно.