How to control the page titles when using the WordPress gallery?

by Fking
7 replies
  • WEB DESIGN
  • |
If you use the Wordpress built-in gallery option to insert bunch of images together into post, you might have stumbled upon the following problem.

When making the gallery, if you have selected the thumbs to go to "attachment page" instead of to the image directly. (Which means that it opens the full sized image in a page instead the image directly.) You might have noticed that the <title> </title> tag of this page is something like:

<title>The title of the post - the title of the image - the title of the blog. </title>

Which is quite long, and if both 3 are on the same topic, it might look like keyword stuffing.

So i'm looking for a way to make Wordpress show just the title of the image in the <title> </title> tag of those attachment pages!


Infact, i'm willing to paypal $20 to the one who give me the solution!


p.s.
things that i've tried that don't work
- getting the original header.php code for the titles from the twentyten theme and replacing it in my current theme > it still outputs the same, so doesn't seem like it's controlled from there.
- adding attachment.php page, copied the original one from the twenty ten theme and added to my current theme, it changes the layout of the page but NOT the title
- plug-ins like All in One Seo Pack controll all the other pages titles but NOT the attachment page
#control #gallery #page #titles #wordpress
  • Profile picture of the author xtrapunch
    You need to make changes in the relevant file--images.php is the template.
    Signature
    >> Web Design, Wordpress & SEO - XtraPunch.com <<
    Web Design & SEO Agency | Serving World Wide from New Delhi, India

    {{ DiscussionBoard.errors[4154171].message }}
  • Profile picture of the author Fking
    i don't have images.php in that template.
    I was told that if i upload attachment.php it will automatically start using it, it did, but that didn't affected the title
    {{ DiscussionBoard.errors[4154307].message }}
  • Profile picture of the author Istvan Horvath
    Hmm... there is no mention of a template file called images.php in the whole WP documentation - only image.php. And the attachment.php works as well, no real need for a MIME-type.php file.

    However, regardless which template file you are using, they ALL call for the same header.php file and the <title>...</title> tag is located there! Which means the way the title is displayed in the browser will NOT change by messing with the template files.

    For what the OP wants the best bet is:

    a) using a plugin that alters the title (html) tag in the header.php [not recommended, I am a plugin minimalist]

    b) using a conditional tag in the title tag... if (is_attachment()) {echo ('whatever');} else...
    Signature

    {{ DiscussionBoard.errors[4155460].message }}
  • Profile picture of the author Fking
    That makes perfect sense! Thanks.

    I started a gig and the elance sites about this, and a guy offered to make a plug-in. I also would prefer the second way. But how would the plug-in change the title, i mean at which level of the page generation. In other words, how's the plug-in solution different than just editing the header.php and adding a condition for attachment pages?
    {{ DiscussionBoard.errors[4155729].message }}
  • Profile picture of the author Istvan Horvath
    I am afraid of plugins made by unknown coders because if they are not perfect they often introduce vulnerabilities (making site open for hacking) or write code that is huge resource hog etc.

    With a minimal PHP-knowledge one can easily modify the template files since WP offers a great variety of Conditional tags
    Signature

    {{ DiscussionBoard.errors[4158029].message }}
  • Profile picture of the author Fking
    I got it sorted out by an oDesk WP expert for $25

    He added condition for the attachment page in the header.php AND
    needed to do the same for the All in one SEO pack, which was blocking the output from the header.php title.

    So, all in one SEO pack was significant part of the problem, for anyone that's using it
    {{ DiscussionBoard.errors[4160773].message }}
    • Profile picture of the author ahmadbasyir
      Originally Posted by Fking View Post

      I got it sorted out by an oDesk WP expert for $25

      He added condition for the attachment page in the header.php AND
      needed to do the same for the All in one SEO pack, which was blocking the output from the header.php title.

      So, all in one SEO pack was significant part of the problem, for anyone that's using it
      Great! You have solve the issue ;-)
      {{ DiscussionBoard.errors[4161555].message }}

Trending Topics