Forums

Use photo as a link back (5 posts)

  1. mafrisky
    Member
    Posted 7 months ago #

    I hope this belongs here.

    Hi,

    i have downloaded a photoblog (Nishita) and right now i'm trying to set the entry / the image of every post as a link back to the older entry.

    So, what i want is. When you click the most recent photo you go back to the one before.
    http://www.blog.brokenstars.org/

    I hope you understand what i mean. I know that <?php previous_post( '%', 'Previous', '' ) ?> is the general link but i dont know where to put and use it.

    Example of what i mean:
    http://blog.jasen.dk/18

  2. mores
    Member
    Posted 7 months ago #

    I guess that won't work, since the Nishita theme does not automatically extract the image, it just calls the_content() which already includes the image.
    So you'd have to do that inside the post editor, create the link around the image manually or something. Which won't work, I think.

    You could modify the theme: use a plugin or a function like post_image() (search the forum, number of possibilities) to call a post's attached image and use it somehow like

    <?php previous_post( '%', 'post_image()', '' ) ?>

    This is just a dummy, but that's how you'd get something like the example site you posted.

  3. mafrisky
    Member
    Posted 7 months ago #

    Thank you, i will try! :)

  4. mores
    Member
    Posted 7 months ago #

    Okay, here's more to get you started.
    I made a site where I used a plugin called post-image.

    My index.php basically looked like this:

    <?php get_header(); ?>
    
    <div id="content_centered">
    
    	<?php
    	if (is_home()) {
    		$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    		query_posts("cat=-3&amp;showposts=1&amp;paged=$page");
    	}
    	?>
    
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<div class="entry">
    		<div class="entrycontent">
    			<?php post_image(); ?><?php the_content(); ?>
    
    		</div>
    	</div>
    
    	<?php endwhile; ?>
    
    	<?php
    		$nextlink="<img src=".get_bloginfo('stylesheet_directory')."/img/next.gif width=21 height=24>";
    		$prevlink="<img src=".get_bloginfo('stylesheet_directory')."/img/prev.gif width=21 height=24>";
    	?>
    	<div id="prevlink"><?php previous_posts_link($prevlink) ?><?php next_post_link('%link', $prevlink, TRUE); ?></div>
    	<div id="nextlink"><?php next_posts_link($nextlink) ?><?php previous_post_link('%link', $nextlink, TRUE); ?></div>
    
    	<?php endif; ?>
    
    </div>
    
    <?php get_footer(); ?>

    So, what I would do with your site is this:

    <?php get_header(); ?>
    
    <div id="content_centered">
    
    	<?php
    	if (is_home()) {
    		$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    		query_posts("cat=-3&amp;showposts=1&amp;paged=$page");
    	}
    	?>
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<div class="entry">
    		<div class="entrycontent">
    		<?php
    			$nextlink=php post_image();
    		?>
    			<?php next_posts_link($nextlink) ?><?php previous_post_link('%link', $nextlink, TRUE); ?>
    
    			<?php the_content(); ?>
    
    			<?php edit_post_link('Edit','', ''); ?>
    
    		</div>
    	</div>
    	<?php endwhile; endif; ?>
    
    </div>
    
    <?php get_footer(); ?>

    To be honest, I can't remember why I needed to use "next_posts_link" and "previous_post_link" in the same line, but you'll figure it out :)

    EDIT: grrr ... change all the "& amp;" to just &

  5. mafrisky
    Member
    Posted 7 months ago #

    ahh thank you so much

    my god that is going to take me ages to understand. just tried, but failed. i'll try later tonight.

    thank you for your time, really.

Reply

You must log in to post.

About this Topic