Все постоы:
<?php
/**
* Template name: Все посты
*/
$parametri = array(
'post_type' => 'post', /* Отбираем только записи. */
'post_status' => 'publish', /* И только опубликованные. */
'posts_per_page' => -1, /* Снимаем ограничение на количество показываемых записей на одну страничку. */
'caller_get_posts' => 1 /* Игнорируем особенности записей-липучек. */
);
$moi_zapros = null;
$moi_zapros = new WP_Query($parametri); /* Формируем новый "нестандартный" запрос. */
if ($moi_zapros->have_posts()):
print '<!DOCTYPE html><html><head><title>Все посты: пример</title></head><body>'.
'<h1>Список всех записей:</h1><ol>';
while ($moi_zapros->have_posts()) : $moi_zapros->the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="Постоянный линк для: <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
print '</ol></body></html>';
endif;
wp_reset_query(); /* Сбрасываем нашу выборку. */
?>Все посты с категориями:
<?php
/* template name: Все посты с категориями */
get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php
// get all the categories from the database
$cats = get_categories();
// loop through the categries
foreach ($cats as $cat) {
// setup the cateogory ID
$cat_id= $cat->term_id;
// Make a header for the cateogry
echo "<h2>".$cat->name."</h2><ul>";
// create a custom wordpress query
query_posts("cat=$cat_id&posts_per_page=1000");
// start the wordpress loop!
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><?php // create our link now that the post is setup ?>
<a href="<?php the_permalink();?>"><?php the_title(); ?></a>
</li>
<?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
<?php echo '</ul><hr/>'; ?>
<?php } // done the foreach statement ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>