Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cedaro/cpt-archives

A WordPress plugin to manage post type archive titles, descriptions, and permalink slugs from the dashboard.
https://github.com/cedaro/cpt-archives

Last synced: about 1 month ago
JSON representation

A WordPress plugin to manage post type archive titles, descriptions, and permalink slugs from the dashboard.

Awesome Lists containing this project

README

        

# CPT Archives [![Build Status](https://travis-ci.org/cedaro/cpt-archives.png?branch=develop)](https://travis-ci.org/cedaro/cpt-archives)

A WordPress plugin to manage post type archive titles, descriptions, and permalink slugs from the dashboard.

__Contributors:__ [Brady Vercher](https://twitter.com/bradyvercher)
__Requires:__ WordPress 4.0+ & PHP 5.4+
__License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)

## Description

*CPT Archives* allows for editing a post type's archive properties by registering a new `cpt_archive` custom post type that's connected to the post type (that's a mind bender). In fact, since it's really nothing more than a CPT, it can be further extended with plugins to add meta boxes for customizing your archive pages in new and interesting ways. By default, archive titles, descriptions and permalinks can be managed through a familiar interface.

Another benefit is that a new "Archive" section appears on the *Appearance → Menus* screen, making it easy to add your post type archives to a menu without using a custom link. Even if your archive slug is changed, you won't have to update the URL in your menu.

![Edit Archive Screen Screenshot](screenshot-1.png)
_Example of an Edit Archive screen. The archive title, description and permalinks can all be updated._

## Usage

To register archive support for an existing post type, add a quick snippet to your theme's `functions.php` file or in a custom plugin like this:

```php
add_action( 'init', function() {
add_post_type_support( 'my_post_type', 'archive' );
} );
```

This automatically adds a submenu in the post type's menu that points directly to the archive edit screen. Behind the scenes, when you register support for an archive this way, a new `cpt_archive` post is created and connected to the post type, so you don't have to do anything else.

### Advanced Registration

For more control, an alternative API is available for registering archives:

```php
add_action( 'init', function() {
if ( empty( $GLOBALS['cptarchives'] ) ) {
return;
}

$GLOBALS['cptarchives']->register_archive( 'my_post_type', array(
'customize_rewrites' => true,
'show_in_menu' => true,
'supports' => array( 'title', 'editor', 'thumbnail' ),
) );
} );
```

Archive Registration Arguments




Argument
Description




customize_rewrites
Whether the post type's rewrites can be customized. Defaults to true. Accepts false, 'archives', and 'posts'.


show_in_menu
Whether the archive should be added to the admin menu. Defaults to true. Also accepts a top level menu item id.


supports
A list of post type features that should be enabled on the archive edit screen.

### Post Type Archive Templates

_CPT Archives_ works with default archive template tags. Additional data for the archive post object can be retrieved using the `$cptarchives` global (be sure it exists before using it).

The `archive-my_post_type.php` template for the example CPT registered above could look something like this:

```php

', '' ); ?>

', '' ); ?>

get_archive_id() ); ?>


get_archive_meta( 'meta_key', true ); ?>

```

## Installation

### Upload

1. Download the [latest release](https://github.com/cedaro/cpt-archives/archive/master.zip) from GitHub.
2. Go to the _Plugins → Add New_ screen in your WordPress admin panel and click the __Upload__ button at the top next to the "Add Plugins" title.
3. Upload the zipped archive.
4. Click the __Activate Plugin__ link after installation completes.

### Manual

1. Download the [latest release](https://github.com/cedaro/cpt-archives/archive/master.zip) from GitHub.
2. Unzip the archive.
3. Copy the folder to `/wp-content/plugins/`.
4. Go to the _Plugins → Installed Plugins_ screen in your WordPress admin panel and click the __Activate__ link under the _CPT Archives_ item.

Read the Codex for more information about [installing plugins manually](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).

### Git

Clone this repository in `/wp-content/plugins/`:

`git clone [email protected]:cedaro/cpt-archives.git`

Then go to the _Plugins → Installed Plugins_ screen in your WordPress admin panel and click the __Activate__ link under the _CPT Archives_ item.