PHP code example of torounit / custom-post-type-permalinks

1. Go to this page and download the library: Download torounit/custom-post-type-permalinks 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/ */

    

torounit / custom-post-type-permalinks example snippets


register_post_type( 'foo',
	array(
		'public' => true,
		'has_archive' => true,
		'rewrite' => array(
			"with_front" => true
		),
		'cptp_permalink_structure' => '%post_id%'
	)
);

add_filter(  'cptp_is_rewrite_supported_by_foo',  '__return_false' );

// or

add_filter(  'cptp_is_rewrite_supported', function ( $support , $post_type ) {
    if ( 'foo' === $post_type ) {
        return false;
    }
    return $support;
}, 10, 2);