• I have a custom field set up that allows me to add as many images as I want to a post which then handles the images with jquery in a slideshow type scroller. I am interested in listing how many images are in the post/scroller so the user can get an idea of how many images to scroll through ex. 1/12, click on “next” this becomes 2/12, etc…

    here is the page so you can get an idea.

    https://www.cdtto.com/site/

    There are only 2 images in the example in the link ( same image, twice)

    Also, the site might break, not tested or optimized, etc..

    Maybe the (1/12) is an overlay on the images, that I am not sure about… but it would be cool.

    Thanks ahead of time, all ideas are welcome!!!!! thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter sam_tots

    (@sam_tots)

    I meant this link :::
    https://www.cdtto.com/site/?p=5

    But the home page works too ??

    Thanks

    you could use the code, that extracts the images from the custom field, and let it count the number of imges.

    or you use the get_post_meta() tag
    (https://codex.www.ads-software.com/Custom_Fields),
    to do something like this:

    <?php $imagelist = get_post_meta($post_id, $key, false);
    $number_of_images = count($imagelist); ?>
    Thread Starter sam_tots

    (@sam_tots)

    Thanks, I will look into that. Still new at php and the wp platform, so things take a bit to get my head around.

    <?php $imagelist = get_post_meta($post_id, $key, false);
    $number_of_images = count($imagelist); ?>

    Then I would echo out the results into a div or whatever would hold it?

    Thanks for you insight, I am having a blast working this site out with WP…

    Thread Starter sam_tots

    (@sam_tots)

    This is what I am using to get the images. If anyone wants to see the code, how would i integrate some other code to get the image #list?

    <div class="featured-bar"></div>
    <div id="sections"><ul>
    <?php $images = get_post_meta( $post->ID , 'image' , false );?>
    <?php if($images) :
    foreach( $images as $image ) { ?>
    <li class="position">
    <div class="featured"><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $image ?>&h=277&w=950&zc=1" alt="<?php the_title(); ?>" width="950" height="277" /></div>
    </li>
    <?php

    Thread Starter sam_tots

    (@sam_tots)

    Ok, I was able to output the number of images in the set based on how many get loaded up with the custom field. It just outputs a static number if; if there are 3 images then the numer “3” is out put.

    here is the code

    <?php $imagelist = get_post_meta($post_id, 'image' , false);
    $number_of_images = count($images); ?>
    <p><?php echo $number_of_images ?></p>

    How would I go about getting it to count? like this 1/3 based on which images is up?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Listing number of fields’ is closed to new replies.