How to make 2 tag feeds show up on 1 page?
-
16-10-2019 - |
Question
I'm looking to create a page within my site that looks like this:
Tag/Category: News
News Post a
News Post b
News Post c
Tag/Category: Events
Event a
Event b
Event c
I'm new to Wordpress. I may not have the wordpress jargon to ask this correctly. Thanks for your help.
Solution
Your best bet is to create a page template with the following code. Also you will need to decide if you will use a tag or category. The code below assumes you are using a category.
<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>
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange