D
D
Dmitry2017-12-07 16:47:39
metadata
Dmitry, 2017-12-07 16:47:39

How to display news on wordpress page?

There is a page for each brand (Roughly speaking, machine profiles), I want something below after the description to conclude 3 latest news. BUT I use tags, and I would like the news to be taken from the tags.
Something like this
5a294673eda5d174880996.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Osadchy, 2017-12-07
@waspmax1

$original_query = $wp_query;
$wp_query = null;
$args=array('posts_per_page'=>5, 'tag' => $brand_name);
$wp_query = new WP_Query( $args );
if ( have_posts() ) :
    while (have_posts()) : the_post();
        echo '<li>';
        the_title();
        echo '</li>';
    endwhile;
endif;
$wp_query = null;
$wp_query = $original_query;
wp_reset_postdata();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question