PHP code example of n5s / page-for-custom-post-type
1. Go to this page and download the library: Download n5s/page-for-custom-post-type 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/ */
n5s / page-for-custom-post-type example snippets
// Check if the current page is a "page for custom post type"
is_page_for_custom_post_type(?string $postType = null): bool
// Get the custom post type associated with a page ID
get_custom_post_type_for_page(int $pageId): ?string
// Get the page ID assigned to a custom post type
get_page_id_for_custom_post_type(?string $postType = null): ?int
// Get the URL for a custom post type's archive page
get_page_url_for_custom_post_type(?string $postType = null): ?string
// The post type slug, or false if not a PFCPT page
$wp_query->is_page_for_custom_post_type
// Boolean for a specific post type (e.g., is_product_page)
$wp_query->is_{posttype}_page