S
S
sugarufc2015-06-16 21:20:34
CMS
sugarufc, 2015-06-16 21:20:34

How to display WordPress posts on another template?

I display posts on the page in the index.php template using if(have_posts())....etc, everything is displayed normally, but when I try to display posts in the same way only in another template (created by me), then on the page nothing is displayed and posts are not displayed. How can I make posts appear exactly in the template that I need? Tell me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sugarufc, 2015-06-16
@sugarufc

I figured it out myself. Here is the solution

<?php $all_posts = get_posts();?>
<?php foreach($all_posts as $post): ?>
// выводим посты
<?php endforeach; ?>

S
Stok29, 2015-06-16
@Stok29

Too little information, give the full code of your template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question