Download the PHP package n5s/page-for-custom-post-type without Composer

On this page you can find all versions of the php package n5s/page-for-custom-post-type. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package page-for-custom-post-type

Page for Custom Post Type

QA Coverage PHPStan Packagist Downloads

Assign any WordPress page as the archive page for a custom post type — just like the native "page for posts" setting.

The problem

WordPress custom post type archives are dynamically generated and can't be edited as regular pages. This creates recurring issues:

Several plugins have attempted to solve this:

While these provided inspiration, none fully replicate WordPress's native behavior.

Approach

This plugin mimics how WordPress handles the posts page (show_on_front=page, page_for_posts={id}). On a posts page request, $wp_query contains both:

This plugin replicates this exact behavior for custom post types, with no extra queries or new functions needed to get your page object.

Setup

Once activated, your public custom post types appear in Settings > Reading.

Settings > Reading

Select any published page to serve as the archive page for each custom post type.

Use page slug as rewrite slug

An optional checkbox lets you use the assigned page's slug as the post type's rewrite slug. This means your archive URL and single post URLs will share the same base path (e.g., /products/ for the archive and /products/my-product/ for a single post).

Warning: Enabling this option changes all single post URLs for the post type. Consider the SEO implications before toggling it on an existing site.

Slug-change protection

Once "Use page slug as rewrite slug" is on, changing the page slug breaks every published URL for that custom post type. The plugin guards both editing surfaces:

Both only fire when the slug actually differs from the saved value, on pages assigned to a CPT with "use page slug" enabled.

Key differences with native CPT archives

CPT archive Page for CPT
Conditionals is_post_type_archive = true
is_archive = true
is_home = true
is_{posttype}_page = true
is_page_for_custom_post_type = $posttype
Queried object WP_Post_Type WP_Post
Template hierarchy archive-{posttype}.php
archive.php
index.php
home-{posttype}.php
home.php
index.php

API

Functions

All functions are available both in the n5s\PageForCustomPostType namespace and in the global namespace.

Query properties

Hooks

Filters

Filter Description
pfcpt/page_ids Modify the array of page ID / post type mappings
pfcpt/post_type_from_id/page_id Filter page ID resolution for a post type
pfcpt/dropdown_page_args Customize the page dropdown arguments in Settings

Actions

Action Description
pfcpt/template_redirect Fires on template_redirect when on a PFCPT page
pfcpt/flush_rewrite_rules Fires before rewrite rules are flushed

Integrations

Polylang

Full multilingual support:

Requires Polylang 3.4+.

Yoast SEO (WordPress SEO)

Requires Yoast SEO 26+.

WPML

Multilingual support via WPML's String Translation:

Requires WPML 4.5+.

The SEO Framework

Requires The SEO Framework 5.1+.

Advanced Custom Fields

Extends the built-in Page Type location rule with one value per bound post type, so field groups can target PFCPT pages. Each value is named {post_type}_page and is labelled with the post type archives label:

The same values are available from the Page Type dropdown in the field group UI.

Requires ACF 6+.

Requirements

Installation

Composer (recommended)

Manual

Download the latest page-for-custom-post-type-X.Y.Z.zip from the releases page and upload it via Plugins > Add New > Upload Plugin. The zip ships with vendor dependencies bundled, so no build step is required.

Upgrading from 0.x

1.0 makes the "use page slug" behavior opt-in (it was previously always on). On upgrade, the plugin automatically enables it for every CPT that already has a page assigned, so existing URLs stay intact. If you'd rather use the default CPT rewrite slugs going forward, uncheck the option per CPT under Settings > Reading.

The legacy procedural API (is_page_for_custom_post_type(), get_page_id_for_custom_post_type(), etc.) is preserved as deprecated shims that forward to the namespaced equivalents. They'll emit a _doing_it_wrong notice when WP_DEBUG is on.

License

GPL-3.0-or-later


All versions of page-for-custom-post-type with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
composer/installers Version ^1.0 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package n5s/page-for-custom-post-type contains the following files

Loading the files please wait ...