Ум всегда в дураках у сердца (Ф. Ларошфуко).
Показать любое количество постов в цикле
Главное меню » Блог-платформа wordpress » Лучшие учебники по темам WordPress » Шпаргалка для начинающих в теме WordPress » Показать любое количество постов в цикле






Статья опубликована: 7 августа 2016

Открыть файл шаблона, где вы хотите, чтобы отобразить n-ое количество последних постов:
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// if everything is in place and ready, let’s start the loop // to display ‘n’ number of posts, we need to execute the loop ‘n’ number of times // so we define a numerical variable called ‘$count’ and set its value to zero // with each iteration of the loop, the value of ‘$count’ will increase by one // after the value of ‘$count’ reaches the specified number, the loop will stop // *USER: change the ‘n’ to the number of posts that you would like to display if ($count == "n") { break; } else { ?> // for CSS styling and layout purposes, we wrap the post content in a div // we then display the entire post content via the ‘the_content()’ function // *USER: change to ‘‘ to display post excerpts instead // here, we continue with the limiting of the number of displayed posts // each iteration of the loop increases the value of ‘$count’ by one // the final two lines complete the loop and close the if statement |