Download the PHP package hard-g/cpt-tax without Composer

On this page you can find all versions of the php package hard-g/cpt-tax. 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 cpt-tax

CPT-TAX

This is a library intended for use in WordPress plugins. The library allows you to ensure that each post of a custom post type is mirrored by a term in a custom taxonomy.

Use cases: An overview

What is the purpose of this mirroring? WordPress famously does not have native support for post-to-post relationships. Many-to-many relationships only exist between taxonomy terms and posts. This library creates a workaround for this limitation.

As an example, imagine you are building a WordPress site about movies. You have three custom post types: Movies, Awards, and Actors. As part of your system, you'd like the ability to associate Actors with both Movies and Awards. Moreover, these relationships must be many-to-many: a single Actor could linked to many Movies, while a single Movie will likely be linked to many Actors.

In your plugin or theme, you would register a taxonomy corresponding to Actors. Then, tell this library to create a link between the taxonomy (say, actor_tax) and the post type (say, actor_pt):

Each post in the actor_pt post type will be mirrored by a term in the actor_tax taxonomy. You can then associate an Actor with a Movie using WP's taxonomy tools:

Later, if you want to query for Movies associated with the Actor, you would use a similar technique:

Similarly, if you want to display a list of Actors associated with a given Movie:

Methods

\HardG\CptTax\Registry::register( $link_key, $post_type, $taxonomy )

Sets up the link between the post type and the taxonomy. Call this sometime shortly after you've registered the taxonomy and the post type. $link_key is a unique identifier for this "pair", which you'll use whenever referencing the pair later.

\HardG\CptTax\Registry::get_post_id_for_term_id( $link_key, $term_id )

Gets the ID of the post associated with a given linked term.

\HardG\CptTax\Registry::get_term_id_for_post_id( $link_key, $post_id )

Gets the ID of the term associated with a given linked post.

Tips

This library does not register the mirrored taxonomy for you. You'll have to do this yourself. In many cases, this taxonomy only meant to provide the links in the database, in which case it's recommended to make the taxonomy non-public:

If you leave the UI enabled, you may wish to disable creation of new terms (all term creation is handled by the library), while still allowing terms to be assigned in the UI to posts:


All versions of cpt-tax with dependencies

PHP Build Version
Package Version
No informations.
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 hard-g/cpt-tax contains the following files

Loading the files please wait ....