PHP code example of ponponumi / ponponcat_post_dataget
1. Go to this page and download the library: Download ponponumi/ponponcat_post_dataget library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ponponumi / ponponcat_post_dataget example snippets
use Ponponumi\PonponcatPostDataget\ArchivePage;
use Ponponumi\PonponcatPostDataget\TopPage;
$topIsNewPost = TopPage::settingIsNewPost();
var_dump($topIsNewPost); // トップページの設定が「最新の投稿」ならtrue、「固定ページ」ならfalse
$topIsFixedPage = TopPage::settingIsFixedPage();
var_dump($topIsFixedPage); // トップページの設定が「固定ページ」ならtrue、「最新の投稿」ならfalse
$postTopPage = TopPage::postTopPageUrlGet();
var_dump($postTopPage); // 戻り値は上記の表のようになります
$postType = ArchivePage::postTypeGet();
var_dump($postType); // 戻り値は上記の表のようになります
$isCustomPostType = ArchivePage::isCustomPostType();
var_dump($isCustomPostType); // カスタム投稿タイプの投稿ページ、アーカイブページならtrue、それ以外はfalse
$postTypeTitle = ArchivePage::postTypeTitleGet("ブログ");
var_dump($postTypeTitle); // カスタム投稿タイプの場合はその投稿タイプの名前、通常の投稿タイプならこの場合は「ブログ」
$postTypeTitle = ArchivePage::postTypeTitleGet("BLOG");
var_dump($postTypeTitle); // カスタム投稿タイプの場合はその投稿タイプの名前、通常の投稿タイプならこの場合は「BLOG」
$allCategoryUrl = ArchivePage::allCategoryUrlGet();
var_dump($allCategoryUrl); // 戻り値は上記の表のようになります
$categorySupportCheck = ArchivePage::categorySupportCheck(true);
var_dump($categorySupportCheck); // カテゴリをサポート中の場合はtrue、サポート中でない場合はfalse、カスタム投稿以外の場合はdefaultの値
$categories = ArchivePage::categoriesGet();
var_dump($categories); // 以下の配列と同じような形式の配列になります。
$result = [
[
"url" => "https://example.com/category/php/",
"name" => "PHP",
],
[
"url" => "https://example.com/category/wordpress/",
"name" => "wordpress",
],
[
"url" => "https://example.com/category/uncategorized/",
"name" => "未分類",
],
];
$years = ArchivePage::yearsGet();
var_dump($years); // 以下の配列と同じような形式の配列になります。
$result = [
"2024",
"2023",
"2022",
];
$months = ArchivePage::monthsGet();
var_dump($months); // 以下の配列と同じような形式の配列になります。
$result = [
"2024/12",
"2024/11",
"2024/7",
];
$dates = ArchivePage::datesGet();
var_dump($dates); // 以下の配列と同じような形式の配列になります。
$result = [
"2024/12/12",
"2024/11/30",
"2024/11/17",
];
$check = ArchivePage::postTypeArchive("event");
var_dump($check); // 「event」という投稿タイプのアーカイブページが有効ならtrue。無効の場合、投稿タイプがない場合はfalse。
$years = ArchivePage::yearsUrlGet("Y年");
var_dump($years); // 以下の配列と同じような形式の配列になります。
$result = [
[
"url" => "https://example.com/2024/",
"name" => "2024年",
],
[
"url" => "https://example.com/2023/",
"name" => "2023年",
],
[
"url" => "https://example.com/2022/",
"name" => "2022年",
],
];
$months = ArchivePage::monthsUrlGet("Y年n月");
var_dump($months); // 以下の配列と同じような形式の配列になります。
$result = [
[
"url" => "https://example.com/2024/12/",
"name" => "2024年12月",
],
[
"url" => "https://example.com/2024/11/",
"name" => "2024年11月",
],
[
"url" => "https://example.com/2024/7/",
"name" => "2024年7月",
],
];
$dates = ArchivePage::datesUrlGet("Y年n月j日");
var_dump($dates); // 以下の配列と同じような形式の配列になります。
$result = [
[
"url" => "https://example.com/2024/12/12/",
"name" => "2024年12月12日",
],
[
"url" => "https://example.com/2024/11/30/",
"name" => "2024年11月30日",
],
[
"url" => "https://example.com/2024/11/17/",
"name" => "2024年11月17日",
],
];
$url = ArchivePage::dateArchiveUrlGet(2025, 6, 12, "event");
var_dump($url); // 「http://localhost:5520/2025/06/12/?post_type=event」と出力されます
$url = ArchivePage::monthArchiveUrlGet(2025, 6, "event");
var_dump($url); // 「http://localhost:5520/2025/06/?post_type=event」と出力されます
$url = ArchivePage::yearArchiveUrlGet(2025, "event");
var_dump($url); // 「http://localhost:5520/2025/?post_type=event」と出力されます
$url = ArchivePage::nowPageDateArchiveUrlGet();
var_dump($url); // 「http://localhost:5520/2025/06/12/?post_type=event」という感じで出力されます
$url = ArchivePage::nowPageMonthArchiveUrlGet();
var_dump($url); // 「http://localhost:5520/2025/06/?post_type=event」という感じで出力されます
$url = ArchivePage::nowPageYearArchiveUrlGet();
var_dump($url); // 「http://localhost:5520/2025/?post_type=event」という感じで出力されます
$categories = get_the_category();
if(!empty($categories)){
$category = $categories[0];
$parentCategories = ParentData::parentCategoriesGet($category, true);
var_dump($parentCategories);
}
$parentCategories = ParentData::nowPageParentCategoriesGet();
if(is_page()){
$fixedPageObject = get_queried_object();
$parentPage = ParentData::fixedPageParentGet($fixedPageObject, true);
var_dump($parentPage);
}
$dateArchive = \Ponponumi\PonponcatPostDataget\ParentData::nowPageDateArchiveGet(
howFar: "d",
yearFormat: "Y年",
monthFormat: "Y年n月",
dayFormat: "Y年n月j日"
);
var_dump($dateArchive);