From c1cdedb75811ec871cae2a85d233477305aeed74 Mon Sep 17 00:00:00 2001 From: Kr1PtunZ Date: Thu, 30 May 2024 15:50:31 +0500 Subject: [PATCH] =?UTF-8?q?API=20=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=BE?= =?UTF-8?q?=D0=B4=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BE=D1=81=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=20permalink=20=D0=B8=20=D0=BF=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=D0=B4=D1=83=D1=8E=D1=89=D0=B8=D1=85=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=B5=D0=BE=D1=80=D0=B8=D1=8F=D0=BC.=20Readm?= =?UTF-8?q?e.txt=20=D0=BF=D0=BE=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BC=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-readmi.txt | 2 ++ wp-content/themes/simple-theme/api-posts/api-posts.php | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/api-readmi.txt b/api-readmi.txt index 4e4d1d7..591f0ae 100644 --- a/api-readmi.txt +++ b/api-readmi.txt @@ -5,5 +5,7 @@ API принимает запросы по URL /wp-json/api-posts/v1/endlessPost Через GET-запрос принимает значение permalink, выводит информацию по посту чей permalink пришёл, далее 10 пермалинков и ID постов из совпадающих категорий. +UPD: Принимает значение paged, отвечает за смену страниц во время поисков постов. Принимает int номера страницы. + Пример: /wp-json/api-posts/v1/endlessPosts?permalink=http://pamtest.ru/641-kak-zarabatyvat-bolshe-na-osago-i-ipotechnom-strahovanii/ \ No newline at end of file diff --git a/wp-content/themes/simple-theme/api-posts/api-posts.php b/wp-content/themes/simple-theme/api-posts/api-posts.php index a82fb17..78ae902 100644 --- a/wp-content/themes/simple-theme/api-posts/api-posts.php +++ b/wp-content/themes/simple-theme/api-posts/api-posts.php @@ -15,6 +15,12 @@ function getEndlessPostsResults($data) global $wpdb; $link = $data['permalink']; + $paged = $data['paged']; + + if ($paged < 0){ + $paged = 1; + } + $result = []; $tag_slug = url_to_postid($link); //Получаем айди поста по пермалинку @@ -38,6 +44,7 @@ function getEndlessPostsResults($data) $args = array( // Создаем массив с параметрами запроса 'tag__and' => $postSlugs, 'posts_per_page' => 10, + 'paged' =>$paged, 'orderby'=>'date', 'order'=> 'DESC' );