Support » Fixing WordPress » Changing Template Images Based on IDs

  • How do I get an image in my theme to change based on Page/Post ID.

    EG: Page ID 3 displays 3.jpg in the sidebar.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thanks iridiax. I’ve read that previously, but I have no knowledge of PHP and am having huge trouble writing the required code and am continually breaking the template.

    Try looking for a plugin that does this. I cannot remember the name of it, but I think that there is one that displays an image thumbnail for a post.

    I still haven’t been able to find a solution to this, could someone please advise?

    This is not simple coding if you want to do it yourself, but to start with, you’d need to get the post and page ID outside of the loop to use it as a php variable. Try a forum search to see if there’s an example of this.

    If you will only ever have a few posts and pages, you could use fixed image names and conditional tags with an if, elseif, elseif,…, else. This option is not really scalable though.

    The easiest option remains a plugin. Try a Google search for one.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Changing Template Images Based on IDs’ is closed to new replies.