Skip to content

megumi-wp-composer/wp-ajaxonomy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

megumi/wp-ajaxonomy

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Installation

Create a composer.json in your plugin root or mu-plugins

{
    "require": {
        "megumi/wp-ajaxonomy": "*"
    }
}

Place the following code into your plugin.

require_once dirname( __FILE__ ) . '/vendor/autoload.php';

Then:

$ composer install

How to use

Megumi\WP\Ajaxonomy has same parameters with register_taxonomy().

<?php
/*
Plugin Name: My Music Library
Version: 0.1-alpha
Description: PLUGIN DESCRIPTION HERE
Author: YOUR NAME HERE
Author URI: YOUR SITE HERE
Plugin URI: PLUGIN SITE HERE
Text Domain: ajax-taxonomy
Domain Path: /languages
*/

require_once dirname( __FILE__ ) . '/vendor/autoload.php';

add_action( 'plugins_loaded', function(){
	$args = array(
		'label'            => 'Music',
	);
	$tax = new Megumi\WP\Ajaxonomy( 'music', 'post', $args );
	$tax->set_order = 'ASC';
	$tax->set_order = 'slug'; // Default is `slug`
	$tax->register();
} );

Then:

Post Screen

Taxonomy Screen