$7
Why Attachment Page Defaults to Article Page?
I have a problem...
Say I have a url:
http://www.yahoo.com/post1
And within this url are photos that are linked to their respective attachment pages. The reason for this is to create more pageviews for readers going through slideshows and such...that every pic would have his url with alt tags, etc. which helps out with SEO and things of that nature. The reader can go from one pic to the next by clicking some type of "next photo" button that is linked to the photo in its own respective page.
So for example the pics in post 1's url will look like this:
http://www.yahoo.com/post1/beyonce-pregnant
http://www.yahoo.com/post1/scarlett-naked
http://www.yahoo.com/post1/rip-mj
http://www.yahoo.com/post1/lovers-reunited
And et cetera...
The problem that I'm having is that when you click on the pic to take you to its url, it always go to http://www.yahoo.com/post1, no matter what pic I click, it takes you the main article where pics are displayed. It's almost as if the browser just refreshes the page.
I thought that there was an issue with my permalinks but they're working because all of my links work other these attachment links as far as I know.
To see an example of what I'm talking about, go here: http://theurbantwist.com/2011/09/14/nba-rookie-josh-selby-says-he-is-not-gay-but-curious/
I didn't do a full fledge photo gallery, but the pic in the post is an example of what's going on. You click the pic and it basically refreshes the page.
The reason I need this is because I'm working on customizing a gallery similar to this page:http://www.hellomagazine.com/music/gallery/200906261527/michael/jackson/gallery/1/
But I would need to get past this roadblock first unless anyone else has any suggestions?
Thanks
Brennen Jones | 09/14/11 at 8:40pm
| Edit
(3) Possible Answers Submitted...
-

Last edited:
09/14/11
8:50pmMilan Petrovic says:When you edit images to add to posts, there is a setting for the URL where the click will point to, and it is called 'Link URL'. You can set it to any url, post url or url to an image. There are 3 buttons to change this URL. You were setting this wrong to post url, you want to change it to image url. Problem is that you must change to all images you already added manually, there is no way to do it automatically. See attached image.
- 09/14/11 10:26pm
Brennen Jones says:According to Wordpress, the post url is supposed to bring up attachment page and it's not. It just refreshes the page.
The url to my source is found here:
http://codex.wordpress.org/Using_Image_and_File_Attachments
I need attachment page to show so from there I can customize it
- 09/14/11 10:26pm
-

Last edited:
09/14/11
9:10pmLuis Abarca says:Edit your images to point to the "file url" instead of "post url", you can also loop trough all the post attachments an show them as a gallery
$args = array( 'post_type' => 'attachment', 'post_parent' => $post->ID );
$attachments = get_posts( $args );
if ($attachments) {
foreach ( $attachments as $post ) {
setup_postdata($post);
the_title();
the_attachment_link($post->ID, false);
$image = wp_get_attachment_image_src( $post->ID, 'medium' );
?>
<a href="<?php echo $image['url'] ?>"><img src="<?php echo $image['url'] ?>" /></a>
<?php
the_excerpt();
}
}
?>
- 09/14/11 9:59pm
Brennen Jones says:I think I understand...for some reason I had originially had it linked to file but was trying to set it up for that gallery example that I showed you. I feel like such a dummy, lol.
I thought that there was a way to link to the attachment file and that there was a general template for me to then customize to get it to that example I showed you.
Where does your code go in template files? - 09/14/11 10:07pm
Luis Abarca says:In the single.php or wherever you need to show the gallery images
- 09/14/11 10:23pm
Brennen Jones says:Just to follow up, I've been in that example I gave you originally, I linked to "post url" which according to wordpress would bring up attachment page. I guess the main thing I'm asking is why isn't this attachment page showing up?
I think that's what I need.
- 09/14/11 9:59pm
-

Last edited:
09/15/11
3:14amIvaylo Draganov says:Hello Brennen,
Whether the "post url" option links to the attachment page correctly depends on the current theme that you are using. There is something called the "Template Hierarchy" in WordPress - it determines which template WP loads when a certain content type is requested.
For image attachments WP first looks for a file named "image.php", then "attachment.php" and if these are not present it uses "single.php".
Some themes are set to redirect to the parent post for image attachment pages. Please check whether your theme contains a file "image.php" or "attachment.php".
And I notice that on the particular example that you gave the attachment has the same slug as the post - maybe that's causing the reload.- 09/15/11 7:42am
Brennen Jones says:That's what I thought initially but I checked and have an attachment.php page and I then created new post and backdated it just so it doesn't show up in recent rss feeds.
Here it is: http://theurbantwist.com/2005/09/15/test/
And notice how the slug is different than the post this time and we're still having the same problem. - 09/15/11 7:45am
Brennen Jones says:Another thing I did was reinstall wordpress and activated default theme, but seems like that doesn't do trick either
- 09/15/11 8:33am
Ivaylo Draganov says:Another thing I did was reinstall wordpress and activated default theme, but seems like that doesn't do trick either
That's odd. Did you try disabling all your plugins? - 09/15/11 10:51am
Brennen Jones says:It's always something simple, isn't it? LOL
I deactivated plugins and reactivated one by one and found out it was my SEO plugin that was messing things up.
http://wordpress.org/extend/plugins/wordpress-seo/
I should've picked up on this. I feel stupid, lol. But I guess that's what this site is for.
I really like this SEO plugin but now may have to find another alternative. I liked this one better than the All-in-One SEO pack.
Do you have any suggestions? - 09/15/11 10:58am
Brennen Jones says:Quick note: I found an option within that SEO plugin that I had to check to make things work.
Also, how do I pick winner? It seems that they've changed some things around since last time I was on here. I voted but it didn't select you as winner.
- 09/15/11 7:42am
This question has expired.
Ivaylo Draganov had additional discourse to offer.
Brennen Jones voted on this question.
Current status of this question: Completed





