• Hi, is it possible to insert two Custom fiels in the same page?
    I’ve created 2 custom meta boxes an pointed them to the same page template, it doesn’t seens to work, but if I repeat the code twice, it repeats twice the meta box. Its hard to explane…

    Something like this:

    This Works:

    <?php
    $actividades = get_post_meta( $post->ID, 'actividades', true );
    echo '<ul class="content-act">';
    foreach( $actividades as $actividade){
    echo '<li>';
    echo '<h2>' . $actividade['titulo'] . '</h2>';
    $attachment_image = wp_get_attachment_image_src($actividade['imagem'], 'full');
    echo '<img src="'. $attachment_image[0].'" width="<'. $attachment_image[1] .'" height="'. $attachment_image[2] .'"/>';
    echo '<p>' . $actividade['descricao'] . '</p>';
    echo '</li>';
    }
    echo '</ul>';
    ?>
    
    <?php
    $actividades = get_post_meta( $post->ID, 'actividades', true );
    echo '<ul class="content-act">';
    foreach( $actividades as $actividade){
    echo '<li>';
    echo '<h2>' . $actividade['titulo'] . '</h2>';
    $attachment_image = wp_get_attachment_image_src($actividade['imagem'], 'full');
    echo '<img src="'. $attachment_image[0].'" width="<'. $attachment_image[1] .'" height="'. $attachment_image[2] .'"/>';
    echo '<p>' . $actividade['descricao'] . '</p>';
    echo '</li>';
    }
    echo '</ul>';
    ?>

    This doesn’t Work:

    <?php
    $actividades = get_post_meta( $post->ID, 'actividades', true );
    echo '<ul class="content-act">';
    foreach( $actividades as $actividade){
    echo '<li>';
    echo '<h2>' . $actividade['titulo'] . '</h2>';
    $attachment_image = wp_get_attachment_image_src($actividade['imagem'], 'full');
    echo '<img src="'. $attachment_image[0].'" width="<'. $attachment_image[1] .'" height="'. $attachment_image[2] .'"/>';
    echo '<p>' . $actividade['descricao'] . '</p>';
    echo '</li>';
    }
    echo '</ul>';
    ?>
    
    <?php
    $services = get_post_meta( $post->ID, 'services', true );
    echo '<ul class="content-act">';
    foreach( $services as $service){
    echo '<li>';
    echo '<h2>' . $service['titulo'] . '</h2>';
    $attachment_image = wp_get_attachment_image_src($service['imagem'], 'full');
    echo '<img src="'. $attachment_image[0].'" width="<'. $attachment_image[1] .'" height="'. $attachment_image[2] .'"/>';
    echo '<p>' . $service['descricao'] . '</p>';
    echo '</li>';
    }
    echo '</ul>';
    ?>

    http://wordpress.org/extend/plugins/custom-fields-creator/

  • The topic ‘Two Custom Fields in Same Page’ is closed to new replies.