PHP code example of spock / shadow-taxonomies

1. Go to this page and download the library: Download spock/shadow-taxonomies 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/ */

    

spock / shadow-taxonomies example snippets


add_action( 'init', function() {
	register_taxonomy(
		'services-tax',
		'staff-cpt',
		array(
			'label'         => __( 'Services', 'text-domain' ),
			'rewrite'       => false,
			'show_tagcloud' => false,
			'hierarchical'  => true,
		)
	);
	// We will make our connection here in the next step.
});

\Shadow_Taxonomy\Core\create_relationship( 'service-cpt', 'service-tax' );

\Shadow_Taxonomy\Core\register_shadow_taxonomy(
	[ 'movies' ],
	[ 'actor' ],
	'_actor',
	[
		'label'         => 'Actors',
		'rewrite'       => false,
		'show_tagcloud' => false,
		'show_ui'       => false,
		'hierarchical'  => false,
		'show_in_menu'  => false,
		'meta_box_cb'   => false,
		'show_in_rest'  => true,
	]
);

\Shadow_Taxonomy\Core\get_the_posts( $post_id, $taxonomy, $cpt )

\Shadow_Taxonomy\Core\get_associated_term( $post, $taxonomy )

\Shadow_Taxonomy\Core\get_associated_post( $term, $post_type )

\Shadow_Taxonomy\Core\get_meta_key( $taxonomy, $type )