• Resolved neil-guevara

    (@neil-guevara)


    Hey guys, wondering if i can get some help. Im trying to add galleries to my wordpress blog using the category function. That is when you add the relevant CSS/PHP to the loop in your index file you can insert all galleries under the category “gallery” that you create. An example of this can be seen on matt’s page.

    Heres what matt said about it :

    I put the intro text, and then the more page split, and the gallery shortcode after that. Here’s the snippet of my index template that does asides and the gallery posts:

    https://php.pastebin.com/m5d433a57

    Obviously the category IDs need to match whatever you’re using. It’s the same technique I wrote about a few years ago for asides:

    https://ma.tt/2004/05/asides/

    I hope that helps! I’ll write more on my blog about this at some point.

    The problem is i cant get the code to work on my index.php file and im wondering if there is some wicked php’er out there that could help me.

    Matt sent me the snippet of the code from his index file so im hoping that someone knows how to add it to my index file to get it to work.

    Thanx everyone for taking the time.

Viewing 9 replies - 16 through 24 (of 24 total)
  • Thread Starter neil-guevara

    (@neil-guevara)

    i removed the hack to see if it was interfering but it wasnt…so no idea

    Try this:

    <div style="display: block;"><div class="date">
    					<span class="month"><?php the_time('M') ?></span>
    					<span class="day"><?php the_time('j') ?></span>
    				</div>
    
    				<div style="float: right; width: 592px; clear: right; margin-top: 10px; margin-bottom: 15px; padding-top: 10px;  margin-left: 5px;">
    					<span class="titles"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></span>
    					<div><img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon1.gif" alt="icon1" /> <?php the_author() ?> | <img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon2.gif" alt="icon2" /> <?php the_category(', ') ?> | <img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon4.gif" alt="icon4" /> <?php the_time('m jS, Y') ?><strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon3.gif" alt="icon3" /><?php comments_popup_link('No Comments &raquo;', '1 Comment &raquo;', '% Comments &raquo;'); ?></div>
    				</div>
    				<div style="clear: both;"></div>
    
    				<div class="post">
    
    <div style="float: left;"><a href="<?php the_permalink(); ?>"><?php echo $thePic; ?></a></div>
    <div style="width: 510px; float: right;"><?php the_content('Read the rest of this entry &raquo;'); ?><br /><small>This album consists of  <?php echo $picCount; ?> pictures.</small>
    </div>
    </div>
    
    				</div>
    Thread Starter neil-guevara

    (@neil-guevara)

    I actually like it the way it is, so kool we are done thanx soooooooooooooooooooo much for your help, your going to be a 1st class wordpress user.

    no prob.

    Thread Starter neil-guevara

    (@neil-guevara)

    it would be great if one piece of code could be created that worked with every theme and inabled the same functions. I know this guy came up with a piece of easy to install code for creating asides so if thats possible then so is this. There are a number of people who are trying to create the same thing and achieve what this gallery code does.

    very much code, visit https://www.ads-software.com/support/topic/165921?replies=3 and use a category-#ID.php file to make a Loop

    Quick question with this setup, how would the post be displayed if you created a post and included it into 2 categories, one for the gallery and an additional one?

    Thanks

    Ok, nevermind my previous question. I’ve got the coded added in and it’s working great except the posts are pulling the same image. So I’ve got 2 different posts with different images, but they both are pulling the first image out of the newer post. Any ideas?

    Here’s my code:

    <div class="post">
    <?php
    				if(in_category(4)) {
    				$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);
    					}
    				}
    
    				$args = array(
    					'post_type' => 'attachment',
    					'numberposts' => null,
    					'post_status' => null,
    					'post_parent' => $post->ID
    					);
    				$attachments = get_posts($args);
    				if ($attachments) {
    					$picCount = count($attachments);
    				}
    				?>
    
    				<!-- $$$$$$$$$$$$$$$$$$ This is the gallery post bit $$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
    <div style="clear: both;"></div>
    				<div class="post">
    
    				<div style="float: right; width: 185px; clear: right; margin-top: 0px; margin-bottom: 0px; padding-top: 0px;  margin-left: 0px;">
    					<h2>Album:<br /><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_time('F jS, Y') ?></a></h2>
    <br />
    <div>This album contains <?php echo $picCount; ?> photos.</div>
    
                                         </div>
    
    					<div style="float: left;"><a href="<?php the_permalink(); ?>"><?php echo $thePic; ?></a></div>
    					<?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    
    <div class="post"><p class="divide">
    		<?php if ('open' == $post-> comment_status) : // kommentare erlaubt, dann ?>
    
    		<?php else : // wenn kommentare deaktiviert, dann ?>
    		<?php endif; ?>
    Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    	</p></div>
    			</div>
    <?php } else { ?>
    
    	<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2><?php the_time('F jS, Y') ?>
    	<?php the_content(__("Read the rest of this entry &raquo;")); ?>
    	<p class="divide">
    		<?php if ('open' == $post-> comment_status) : // kommentare erlaubt, dann ?>
    
    		<?php else : // wenn kommentare deaktiviert, dann ?>
    		<?php endif; ?>
    Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    	</p>
    
    <?php } ?>
    
    	</div>
    	<?php endwhile; ?>
    	<?php else : ?>
    
    	<div class="post">
    <img src="<?php bloginfo('template_directory'); ?>/images/404error.gif">
    <h2 align="center">Sorry, but this page does not exist.</h2>
    	</div>
    
    	<?php endif; ?>
    	<div class="post" align="center">
    <?php posts_nav_link('&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;','&laquo; Latest Entries','Previous Entries &raquo;'); ?>
             </div>

    The code Kalon gave on comment#2 worked very well till I upgraded to WP 2.6.
    Now $picCount always shows 3 even if there are more pics…
    Any idea ?

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘wordpress 2.5 gallery with albums’ is closed to new replies.