WordPress.org

Ready to get started?Download WordPress

Forums

Changing Template Images Based on IDs (6 posts)

  1. Beau Nidle
    Member
    Posted 5 years ago #

    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.

  2. iridiax
    Member
    Posted 5 years ago #

  3. Beau Nidle
    Member
    Posted 5 years ago #

    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.

  4. iridiax
    Member
    Posted 5 years ago #

    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.

  5. Beau Nidle
    Member
    Posted 5 years ago #

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

  6. iridiax
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic