WordPress.org

Ready to get started?Download WordPress

Forums

get_post_meta with array for multiple custom values for a single key (2 posts)

  1. lukeshumard
    Member
    Posted 4 years ago #

    I'm trying to build an online portfolio using the Flutter plugin. I have a duplicate group on a page that has two fields, portfolio-image-medium and portfolio-image-large. These are for the two different sizes the images will be (no way!). Displaying this using Flutter is pretty infuriating, so I'm trying to do this with get_post_meta and calling on each duplicate from the array. All of the images via portfolio-image-medium should display under div class="portfolioimages" with links to its respective portfolio-image-large.

    What I have now (below) works, but it isn't exactly what I want, as I don't think it's optimized as well as it could be. For example, I don't know how to call the same portfolio-image-large as the portfolio-image-medium it relates to. I know this is probably some sort of count in the array and keeping it consistent, but I'm having a brain fart in terms of what I need to do. The code below just calls on portfolio-image-medium and modifies it via Flutter, so it doesn't use portfolio-image-large at all. I'd like to change that. Any help is appreciated. Thanks!

    <?php
    $portimgmed = get_post_meta($cchild->ID, 'portfolio-image-medium', false);
    $portimglrg = get_post_meta($cchild->ID, 'portfolio-image-large', false);
    ?>
       <div class="portfolioitem" id="<?php echo $portslug; ?>">
       <div class="portfolioimages">
          <?php foreach ($portimgmed as $mediumimage) {
             $largeimage = get_post_meta($cchild->ID, 'portfolio-image-large', true);
             $count++; ?>
             <div class="portfolioimage">
                <a href="<?php echo pt(); ?>?src=/evanmannweiler.com/wp-content/files_flutter/<?php echo $mediumimage; ?>&w=800" class="fancybox"><img src="<?php echo pt(); ?>?src=/evanmannweiler.com/wp-content/files_flutter/<?php echo $mediumimage; ?>&w=323&bg=fffaef" alt="" /></a>
             </div>
          <?php }; ?>
  2. vtxyzzy
    Member
    Posted 4 years ago #

    I have not tested this, but it may work;

    <?php foreach ($portimgmed as $mediumimage) {
             $largeimage = portimglrg[$count++]; ?>
             <div class="portfolioimage">
                <!-- display the images -->
             </div>
          <?php }; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic