Support Forum » User Profile

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: How to retrieve custom fields in attachment loop? #20459
    CarmineSassoCarmineSasso
    Participant

    Hi,
    starting from this official guide for image_advanced https://docs.metabox.io/fields/image-advanced/
    how can I stamp the custom fields associated with the specific image?

    Thank you

    in reply to: How to retrieve custom fields in attachment loop? #20455
    CarmineSassoCarmineSasso
    Participant

    To summary my issue.
    I have a post with an image_advanced.
    For each image (attachment), I have added some custom fields.
    When I loop the image advanced, I want to show the custom fields of the attachment, but at the moment this feature seems to be impossible to do.

    in reply to: How to retrieve custom fields in attachment loop? #20454
    CarmineSassoCarmineSasso
    Participant

    yes, I show the "standard" information alt, full_url ecc.
    The issue is on the custom field added to the standard attachment. I attach the code

    $prefix = 'media_';

    $meta_boxes[] = array (
        'title' => esc_html__( 'Descrizione Media', 'text-domain' ),
        'id' => 'descrizione-media',
        'post_types' => array(
            0 => 'attachment',
        ),
        'context' => 'normal',
        'priority' => 'high',
        'autosave' => true,
        'fields' => array(
            array (
                'id' => $prefix . 'Frase2',
                'type' => 'textarea',
                'name' => esc_html__( 'Frase', 'text-domain' ),
            ),
            array (
                'id' => $prefix . 'tag_autori',
                'type' => 'taxonomy',
                'name' => esc_html__( 'Autore', 'text-domain' ),
                'taxonomy' => 'autori',
                'field_type' => 'select',
            ),
            array (
                'id' => $prefix . 'tag_immagine',
                'type' => 'taxonomy',
                'name' => esc_html__( 'Tipologia di immagine', 'text-domain' ),
                'taxonomy' => 'tipologia-di-immagine',
                'field_type' => 'checkbox_list',
                'inline' => true,
            ),
        ),
    );
    
    return $meta_boxes;
    

    those fields are attached to the attachment type.

    In my code what is not shown is the "Frase2" custom field

    <?php
    $images = rwmb_meta(‘select_immagini’);
    foreach ($images as $index => $image) {
    ?>
    <figure>
    ” alt=”<?php echo $image[‘alt’]; ?>”>
    <figcaption><?php echo rwmb_meta(“Frase2”); ?></figcaption>
    </figure>
    <?php } ?>

    in reply to: How to retrieve custom fields in attachment loop? #20451
    CarmineSassoCarmineSasso
    Participant

    Hi,
    I try to better explain my case.
    I have a custom post type with a custom field (an image_advanced) and I want to print all the custom fields of all the images. This because I extended the media attachments with some custom fields.

    This is the code of the image_advanced. In the previous comment, I changed the id because of the Italian. this is the original code

    array (
    'id' => $prefix . 'select_immagini',
    'type' => 'image_advanced',
    'name' => esc_html__( 'Seleziona immagini', 'text-domain' ),
    'max_file_uploads' => 30,
    'max_status' => 1,
    'add_to_wpseo_analysis' => true,
    ),

    Thank you

Viewing 4 posts - 1 through 4 (of 4 total)