Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal



Answers (4)


Jim Dugan answers:

I'm not clear on what you want but maybe this will help:

Jim Dugan comments:

Also this:
Within Same Category, Excluding One

Displays link to next post in the same category, as long as it is not in category 13 (the category ID #). You can change the number to any category you wish to exclude. Exclude multiple categories by using " and " as a delimiter.
Next post in category

<?php next_post_link('%link', 'Next post in category', TRUE, '13'); ?>

Lucas Wynne comments:

That is specifically what I don't want.

For clarification:
I am using this code in a customized image gallery. post_link codes do not work for it.

I am looking to add customizable link text to the code I provided.


enodekciw answers:

what about something like this:
<?php $next_link = get_next_posts_link(); ?>
<?php $prev_link = get_previous_posts_link(); ?>



Nilesh shiragave answers:

Which plugin you are using for the custom image gallery? All developers can not answer your question if you are providing less information.

You are saying you are using a custom image gallery. Then you must provide source code of the gallery result page as no one can help without this as we don't know how the result page has been created.

Lucas Wynne comments:

<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<!-- Post title -->
<div class="full_header">

<h1 class="full"><?php echo get_the_title($post->post_parent); ?></h1>


<div style="background:#1a1a1a">

<div class="gallery_entry">
$parent = $post->post_parent;
$attachments = array_values(get_children(array('post_parent' => $post->post_parent, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'ID') ) );

foreach ( $attachments as $k => $attachment )
if ( $attachment->ID == $post->ID )

$next = $k+1;
$prev = $k-1;
$next_link = "";
$prev_link = "";

if ( isset($attachments[$next]) )
$next_exists = 1;
$next_link = "<a href='" . get_attachment_link( $attachments[$next]->ID ) . "'> next image >></a>";
$img_link = "<a href='" . get_attachment_link( $attachments[$next]->ID ) . "'>";

if ( isset($attachments[$prev]) )
$prev_exists = 1;
$prev_link = "<a href='" . get_attachment_link( $attachments[$prev]->ID ) . "'> << previous image</a>";
if (!$next_exists)
$img_link = "<a href='" . get_attachment_link( $attachments[$prev]->ID ) . "'>";

if (!$next_exists and !$prev_exists)
$img_link = "<a href='" . get_attachment_link( $attachments[$k]->ID ) . "'>";

$img_url = wp_get_attachment_url( $attachments[$k]->ID );
if (sizeof($matches) > 1)
$fn = "/home/phasenet/public_html" . $matches[1];
$exif_data = read_exif_data($fn);

<p class="attachment"><?php echo $img_link; echo wp_get_attachment_image( $post->ID, 'medium' ); ?></a></p>
<div class="caption"><?php if ( !empty($post->post_excerpt) ) the_excerpt(); ?></div>

<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>


<div class="navigation">
<div class="alignleft"><?php echo $next_link ?></div>
<div class="alignright"><?php echo $next_link ?></div>
<br class="clear" />


<?php comments_template(); ?>
<?php endwhile; else: ?>
<p>Sorry, no attachments matched your criteria.</p>
<?php endif; ?>
<?php get_footer(); ?>


S├ębastien | French WordpressDesigner answers:

Could you paste here the code you use to display your slide please ?
And what do you want to display in the place of "next image" ? The title of the next image ?

Lucas Wynne comments:

Check the comment I made on the user above.

I want to display whatever I type in manually. So for now just make it say "Next" and "Previous".