Advanced UsageFREE

Docs Modules Post Types Advanced Usage

#Export/Import Post Types

It is possible to export and import Post Types in a Json file using the ACF > Tools menu. Post Types can also be exported in PHP format, to manually register them in the functions.php file. Those tools are also available directly within the Dynamic Post Types UI.

#Advanced Settings

The module comes with additional settings that allows an advanced control over post types.

SettingDescription
Front: Archive Posts per pageSet posts per page
Front: Archive Order/OrderbySet order/orderby setting
Front: Single TemplateSet custom template. Example: my-single.php
Front: Archive TemplateSet custom template: Example: my-archive.php
Admin: List Posts Per PageSet posts per page
Admin: List Order/Order bySet order/orderby setting
Admin: Archive PageAdd an Archive Option Page under the post type menu. See Post Type Archive location

#Register Post Types in PHP

Post Types can be registered using register_post_type() and benefit from ACF Extended advanced settings like “Front: Archive Posts per page” or “Admin: List Order/Order by”. See documentation. Usage example:

add_action('init', 'my_init');
function my_init(){
    
    register_post_type('my-post-type', array(
        
        // label
        'label' => 'My Post Type',
        
        // front: archive
        'acfe_archive_template' => 'my-archive.php',
        'acfe_archive_ppp' => 999,
        'acfe_archive_orderby' => 'title',
        'acfe_archive_order' => 'ASC',
        
        // front: single
        'acfe_single_template' => 'my-single.php',
        
        // admin
        'acfe_admin_archive' => true,
        'acfe_admin_ppp' => 999,
        'acfe_admin_orderby' => 'title',
        'acfe_admin_order' => 'ASC',
        
    ));
    
}

#Existing Post Types

Advanced settings can be used in already existing post types using the register_post_type_args hook. See documentation. Usage example:

add_filter('register_post_type_args', 'my_post_type_args', 10, 2);
function my_post_type_args($args, $post_type){
    
    // target "my-post-type"
    if($post_type === 'my-post-type'){
    
        // set front: posts per page
        $args['acfe_archive_ppp'] = 999;
    
    }
    
    // return
    return $args;
    
}