Support » Fixing WordPress » A different image on each Page

  • Resolved buskerdog


    I’m sure this can be made to work: I want to call up an image with this:

    ‘<?php the_title(); ?>_image.jpg’

    …and name my images specifically for each page. (home_image.jpg, contact_image.jpg, etc…)

    It works for pages with one name titles but I can’t get it to use the Page Slugs over the Page Titles, so Pages with titles like “The Author” don’t work. I’ve tried replacing the_title with a lot of other stuff but nothing works. What’s needed? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • buskerdog


    Alright, I set up Permalinks and I think it’s working now…

    EDIT: It’s not. Even with Permalinks in effect it doesn’t work. Is there no code to use the Page Slug in a way like that?



    The page slug is for “internal” use only, say for Permalinks. It is not hard coded.
    Instead, use the ID of the Page with this command: <?php the_ID(); ?>
    But, in order to work, this tag must be within The Loop.



    Thanks. If I name the image files like 1_image.jpg then that works. Not quite as elegant as what I wanted but it’ll do.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘A different image on each Page’ is closed to new replies.