Answer the question
In order to leave comments, you need to log in
2 Wordpress Post Templates?
There are 2 Wordpress post templates, how you can display posts according to two templates.
In the admin panel, the first post automatically takes the first template, then fill in the second post and automatically take the second template, that is, you need to use post templates in turn for any posts.
Answer the question
In order to leave comments, you need to log in
I understood the task as follows: display post cards in two different templates in turn. If the problem is different, correct it.
We find the desired template file in the theme (for example, index.php) and the WordPress cycle, it will look something like this:
while (have_posts): the_post();
//Загружаем шаблон записи
get_template_part('content', 'single');
endwhile;
//Добавим переменную-счетчик, чтобы различать четные и нечетные посты
$counter = 0;
while (have_posts): the_post();
//добавим проверку на четность
if ( $counter % 2 == 0 ):
//загружаем первый шаблон для четных
get_template_part('template', 'one');
else:
//загружаем второй шаблон в другом случае
get_template_part('template', 'two');
endif;
$counter++;
endwhile;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question