Custom post types

Cloud Customer Area per WordPress
Testato con WP 5.4.1
Tot. download: 15718
Versione FREE
Versione PRO
Descrizione

Documentazione

Il plugin mette a disposizione alcuni hook da utilizzare per personalizzare al massimo il risultato finale.

Shortcode

Mostra il valore di un campo specifico:

[custom-field id="field_XXXX"]

Mostra i termini utilizzati di una tassonomia:

[custom-tax id="tax_XXXX"]

Aggiungere la compatibilità per il tuo tema

function add_theme_compatibility( $themes ){
    $themes['YOURTHEMESLUG'] = array(
        'single_template' => get_template_directory() . '/single.php',
        'replace_type' => 'preg',
        'replace' => array("#while(.+)endwhile;#s"),
        'after' => " echo '</main>'; ",
    );
    return $themes;
}
add_filter( 'add_theme_compatibility_template', 'add_theme_compatibility' );
function add_theme_compatibility_2( $themes ){
    $themes['YOURTHEMESLUG'] = array(
        'single_template' => get_template_directory() . '/single.php',
        'replace_type' => 'string',
        'replace' => "get_template_part( 'content', 'single' )",
    );
    return $themes;
}
add_filter( 'add_theme_compatibility_template', 'add_theme_compatibility_2' );

Aggiungere un tipo di campo

function add_field_type_to_ui( $types ){
$types['field-type'] = __( 'IMAGE', 'custom-post-types' );
return $types;
}
add_filter('form_edit_field_types', 'add_field_type_to_ui' );

function add_field_type_to_editor( $id, $type, $value, $required ){
if($type == 'field-type'){ ?>
<div class="file-uploader-field">
<input id="<?php echo $id;?>_field" type="text" name="custom_field[<?php echo $id;?>]" value="<?php echo $value;?>"<?php echo $required;?>/>
<input type="button" class="button-primary" value="<?php _e( 'Select', 'custom-post-types' ); ?>" data-file="<?php echo $id;?>_field" />
</div>
<?php }
}
add_action('view_field_types', 'add_field_type_to_editor', 10, 4 );

function add_field_type_frontend( $value, $field_type, $id ){
if($field_type == 'field-type'){
$value = '<img src="' . $value . '" class="field-'.$id.'">';
}
return $value;
}
add_filter('get_field_from_shortcode', 'add_field_type_frontend', 10, 3 );

Modificare la dicitura ”File allegato” per il frontend

function edit_field_file_label( $label ){
$label = 'Scarica il file';
return $label;
}
add_filter('field_type_file_label', 'edit_field_file_label' );