• Hi folks,

    I have the following code:

    <?php
    		$args = array(
    			'post_type' => 'attachment',
    			'numberposts' => 1,
    			'post_status' => null,
    			'post_parent' => $post->ID,
    			'exclude'     => get_post_thumbnail_id()
    		);
    		$attachments = get_posts($args);
    			if ($attachments) {
    				foreach ($attachments as $attachment) {
    					the_attachment_link($attachment->ID, true, false, true);
    				}
    			}
    		?>

    Which works fine, except the permalink that it’s linking to outputs the URL twice. This is the HTML it outputs:

    <a href='REMOVED_FOR_PRIVACY_c8/print/issue-3-3/issue3-3/' title='Issue 3.3'><img width="600" height="933" src="REMOVED_FOR_PRIVACY_c8/wp-content/uploads/2012/08/issue3-3.jpg" class="attachment-full" alt="Issue 3.3" title="Issue 3.3" /></a>

    As you can see from the href, it’s got the ‘issue-3-3’ twice. However, the permalink code for the title is outputting correctly:

    <h3><a href="REMOVED_FOR_PRIVACY_c8/print/issue-3-3/" title="Issue #3.3" >Issue #3.3</a></h3>

    Any help in fixing this would be most appreciated.

    Thanks,
    R

The topic ‘WP the_attachment_link permalink’ is closed to new replies.