Я перекодирую файл архива WordPress.
Не знаю, как писать? Изучите, затем перестаньте видеть фрагмент кода, подобного этому.
<?php
$args1 = array(
'post_type' => 'post',
'posts_per_page' => '1'
);
$query1 = new WP_Query( $args1 );
// Check that we have query results.
if ( $query1->have_posts() ) {
// Start looping over the query results.
while ( $query1->have_posts() ) {
$query1->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail("thumbnail",array( "title" => get_the_title(),"alt" => get_the_title() ));?>
</a>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
<?php the_excerpt(); ?>
</article>
<?php
}
}
// Restore original post data.
wp_reset_postdata();
// Second query arguments.
$args2 = array(
'post_type' => 'post',
'posts_per_page' => '2',
'offset' => '1'
);
// Second custom query.
$query2 = new WP_Query( $args2 );
// Check that we have query results.
if ( $query2->have_posts() ) {
echo '<ul class="more-posts">';
// Start looping over the query results.
while ( $query2->have_posts() ) {
$query2->the_post();
?>
<li <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail("thumbnail",array( "title" => get_the_title(),"alt" => get_the_title() ));?>
<?php the_title(); ?>
</a>
</li>
<?php }
echo '</ul>';
}
wp_reset_postdata();
?>
Это работает довольно хорошо, но когда я перехожу к другим категориям, сообщения отображаются одинаково. Как он может определить категории и экспортировать нужную статью? Спасибо