0

I got this custom portfolio php file here:

http://pastebin.com/B4ZgdQZT

or you can see it below at the end of the question...

The problem is that I can't manage to show the image title. I tried different ways but I can't manage to make it work. Always all the images shows the same title from the first attached image when I want that every image on the portfolio page to show their exact title. not the same one with the first attached one.

The tile of the image goes in the line 57

Any suggestions?

<?php
if($grid_gallery == "1 column"){
    $portfolio_container = "container-24";
    $portfolio_category = true;
    $portfolio_img_w = 1000;
    $portfolio_img_h = 300;
} elseif ($grid_gallery == "2 columns") {
    $portfolio_container = "container-12";
    $portfolio_category = true;
    $portfolio_img_w = 500;
    $portfolio_img_h = 300;
} elseif ($grid_gallery == "3 columns") {
    $portfolio_container = "container-8";
    $portfolio_small_tag = "-small";
    $portfolio_img_w = 500;
    $portfolio_img_h = 300;
} elseif ($grid_gallery == "4 columns") {
    $portfolio_container = "container-6";
    $portfolio_small_tag = "-small";
    $portfolio_img_w = 193;
    $portfolio_img_h = 112;
}

$gallery_images = json_decode(htmlspecialchars_decode(get_post_meta(get_the_ID(), 'glocal_company_gallery', true)));
$count_arr = count((array)$gallery_images);
if(is_object($gallery_images) && $count_arr >= 1) :
    $i = 1;
    $k = 1;
    foreach($gallery_images as $_img) { if($k == $i) { $main = wp_get_attachment_image_src($_img); } $k++; }
    $k = 1;
    foreach($gallery_images as $_img) :

        $image = wp_get_attachment_image_src($_img, 'full');   ?>
        <div class="portfolio-container <?php echo $portfolio_container; ?>">
            <div class="portfolio-listing<?php echo $portfolio_small_tag; ?> block">
                <div class="portfolio-image">

               <a href="<?php echo $image[0] ?>" class="portfolio-enlarge">

                <img src="<?php echo vt_resizer($image[0], $portfolio_img_w, $portfolio_img_h); ?>" alt="<?php the_title() ?>" title="<?php the_title(); ?>" />

                </a>

                </div>
                <?php if($portfolio_category == true): ?>
                <div class="portfolio-description development clearfix">
                    <div class="portfolio-title-category">
                        <div class="portfolio-title"><?php the_title() ?></div>
                        <div class="portfolio-category text-colorful"><?php echo __('Portfolio','glocal_site'); ?></div>
                    </div>
                    <a href="<?php echo $image[0] ?>" class="portfolio-enlarge" target="_blank"></a>
                </div>
                <?php else: ?>
                <div class="portfolio-title">
                <a href="<?php echo $image[0] ?>" class="portfolio-enlarge">

                TITLE GOES HERE

                </a>
                </div>

                <?php endif; ?>
            </div>
        </div>
        <?php $k++;
    endforeach;
endif;
4
  • hey your demo link is not work. please write proper demo URL – Amit Mishra Dec 23 '14 at 12:16
  • Please do't use third party services to host your code, add your code to your question directly – Pieter Goosen Dec 23 '14 at 12:21
  • I tried to add my code directly but it was not getting it right. It deleted alot of the lines that were in the code... – user2623187 Dec 23 '14 at 18:17
  • I have updated the code, please can anyone help me solve my problem??? – user2623187 Dec 23 '14 at 21:44
0

Instead of the_title() try this: echo get_the_title($_img). It should only work inside the foreach loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.