Как сделать 2 -й фиды с меткой на 1 странице?
-
16-10-2019 - |
Вопрос
Я хочу создать страницу на моем сайте, которая выглядит так:
Тег/категория: новости
Новости сообщения а
Новости пост б
Новости пост c
Тег/категория: события
Событие а
Событие б
Событие c
Я новичок в WordPress. У меня может не быть жаргона WordPress, чтобы спрашивать об этом правильно. Спасибо за вашу помощь.
Решение
Лучше всего создать шаблон страницы со следующим кодом. Также вам нужно будет решить, будете ли вы использовать тег или категорию. Приведенный ниже код предполагает, что вы используете категорию.
<div class="news">
<?php
//The Query
wp_query('showposts=5&category_name=News');
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="post_content">
<?php the_excerpt(); ?>
</div>
<?
endwhile;
endif;
//Reset Query
wp_reset_query();
?>
</div>
<div class="events">
<?php
//The Query
wp_query('showposts=5&category_name=Events');
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="post_content">
<?php the_excerpt(); ?>
</div>
<?
endwhile;
endif;
//Reset Query
wp_reset_query();
?>
</div>
Не связан с wordpress.stackexchange