WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields Creator
Two Custom Fields in Same Page (1 post)

  1. Pedromrferreira
    Member
    Posted 1 year ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by Pedromrferreira
  • This topic is not resolved
  • WordPress version: 3.3.1

Tags

No tags yet.