• I’ve been working with the new built in gallery feature and I’m not getting the gallery navigation (by that, I mean the ‘next’ and ‘previous’ thumbnails seen on Matt’s installation and in his screencast). Is there something special that needs to happen in the template for that to happen? A new set of tags to include or somesuch? And I didn’t see a way to do the links like Matt has (like the View Full Resolution link). I didn’t see any reference to any new template tags on the page about gallery shortcodes. Is there another reference somewhere? Pointers or answers or even just vague clues would be much appreciated.

    Also, I am not able to upload more than one file at a time (as Matt showed in his screencast). That seems less about themes and more like a bug, but I thought I may as well mention it to see if it’s just me or something that’s across the board.

Viewing 15 replies - 16 through 30 (of 33 total)
  • I almost have it working using the stock install. My problem is that I cannot get wp_get_attachment_image to work on my index page, which means I cannot get the image to show up. I really feel if I can figure out why it won’t work (or is working on image.php) then I will have it sorted.

    Once I get it worked out, I’ll post my results here. Hopefully someone will solve it before me, since I am getting pretty frustrated at this point.

    Anyone know why wp_get_attachment_image would work on image.php but not index.php? I have tried passing the post ID as both a variable and the actual post number, but it refuses to work.

    Getting somewhere concerning showing the first image of a gallery but linking to the gallery vs the image itself.

    I am using a modified version of the code found on the get_posts page. This code is located in my index.php file. Code is below:

    <?php
    if(in_category(14)) {
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => 1,
    	'order' => 'ASC',
    	'post_status' => null,
    	'post_parent' => $post->ID
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		$thePic = wp_get_attachment_image($attachment->ID);
    	}
    }
    ?>
    <p><a href="<?php the_permalink(); ?>"><?php echo $thePic; ?></a></p>
    <?php } else {
    the_content('Read the rest of this entry &raquo;');
    } ?>

    For reference, category 14 is my “photos” category. I can get the count by using a similar method. Code is below:

    <?php
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => null,
    	'post_status' => null,
    	'post_parent' => $post->ID
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	$picCount = count($attachments);
    }
    ?>
    <p>There are <?php echo $picCount; ?> pictures in this gallery.</p>

    Finally, I put general information about the gallery in the excerpt tag, and use the template tag the_excerpt to display it.

    Hope this helps some folks.

    onedeep, good job! That works to pull the first image and properly link it to the gallery. You’re a hero.

    So what does this code enable you to do? Have the index of your blog only show the first image of a pic, then link to the page to show them all?

    Or does it create a ‘gallery’ for you to show all the posts that have pics?

    If I understand your questions correctly, I believe it can be used to do both.

    If you put it in your index.php file, it shows the first picture of that post’s gallery, with a link to the full post, which does show all of the pictures in that particular gallery. Your other posts will continue to show as normal.

    If you put it in your archive.php file, it will do basically the same thing, but because it is only showing from one category, it is essentially creating a gallery of galleries

    Both of these are assuming you are marking all of your gallery posts with gallery specific category.

    Excellent news. ??

    I altered your code ever so slightly…

    <?php
    if(in_category(14)) {
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => 1,
    	'order' => 'ASC',
    	'post_status' => null,
    	'post_parent' => $post->ID
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		$thePic = wp_get_attachment_image($attachment->ID);
    	}
    }
    ?>
    <p><a href="<?php the_permalink(); ?>"><?php echo $thePic; ?></a></p>
    <?php continue; } else {
    the_content('Read the rest of this entry &raquo;');
    } ?>

    If you notice, at the end of thePic, I added a continue;

    This accomplishes one thing on my blog… the post was showing up twice. Now I can go in and format this directly, and it doesn’t require any truly extra work within the code other than leaving this in there.

    Interestingly enough, and I can’t figure out why for sure, but when using this in theloop.php when k2 is enabled, the gallery doesn’t function properly – instead it just constantly shows the single picture.

    Nevertheless…

    You have brought me a million steps closer to what I was hoping the true functionality would be with the gallery.

    Applaud and gratitude all around ??

    Also, if you switch ASC to DESC you can pull the last image instead of the first, or you can use it to pull two different images.

    For those of you using K2… The issue is in the theme itself. Both the single.php and index.php (main site and single post) utilize the same loop in “theloop.php.” Due to this, just simply adding the previously mentioned code did not properly allow for the viewing of the actual gallery page within the “single” area.

    Thus, changing :

    if(in_category(3)) {

    to:

    if(!is_single() && in_category(3)) {

    This alters the rendering of a single page in order to produce the ‘normal’ look as opposed to the altered look for something similar to ma.tt.

    hi ?? i keep trying but i think this is way out of my league, is there any way i could have text instead of the thumbnail images in the navigation? thanks.

    You’d have to change wp_get_attachment_link() located in post-template.php from this:

    return "<a href='$url' title='$post_title'>$link_text</a>";

    to this:

    return "<a href='$url' title='$post_title'>$post_title</a>";

    I think. I haven’t tried that myself, but it should work.

    Below the two thumbnails used for last/next navigation (in image.php), I also added:

    <p align="center">Return to the post: <a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a>

    (which I basically took straight from the heading code, plus adding the “Return to the post: ” wording) — that always shows an obvious link for visitors to return to the post (without having to guess that the heading does the same thing).

    Maybe that’ll help anyone else reading this page.

    Can anyone tell me how to add “previous” and “next” text links rather than using the thumbnail navigation? (And how only show these links if there is a previous and/or next image to link to…?)

    There are instructions here on how to replace the thumbnail navigation with text links.

    In onedeep’s example… he is using it for gallery category 14… how is it possible to get a picture from subpages/children just like ma.tt’s photo gallery

Viewing 15 replies - 16 through 30 (of 33 total)
  • The topic ‘Gallery Navigation’ is closed to new replies.