pages (not posts). conditional. insert image (4 posts)

  1. rwilliams1961
    Posted 5 years ago #

    I have looked but can't find a solution. Here we go:

    I am using WP for a CMS and thus have pages and not posts. There are approximately 25 pages. Pages will use one of eight background images/colors. Additionally, each page will have one unique image that is positioned using CSS (images are not embedded within text).

    How do I achieve each of these steps?

    I am BRAND NEW to WP and this site will be used by one of my website clients. So the solution has to be easy for them and, hopefully, not require they edit the template code.

    Thanks so much.

  2. nsathees
    Posted 5 years ago #

    use the is_page() template tag.

    more info here . . .


  3. rwilliams1961
    Posted 5 years ago #

    Forgive me, but I don't understand how this would work for my client - who I want to keep out of the code.

    How do they insert an employee's picture into a predefined div tag. For example, they hire a new chef and they create a page for him. They have a photo that is cut to an exact size for insertion into the div tag. That photo ONLY goes on the chef's page.

    I apologize for my ignorance.

  4. Michael
    Part-Time Forum Moderator
    Posted 5 years ago #

    Pages will use one of eight background images/colors.

    random? or selected?

    as for the image in a predefined div for the new chef on a page:

    if(is_page()) {
    if(!file_exists(TEMPLATEPATH.'/images/'.$image)) { $image='picture_placeholder.jpg'; }
    echo '<img src="'.get_bloginfo('template_url').'/images/'.$image.'"/>';
    } ?>

    adjust the name, type and location of the image in above code to your needs. the check if the image exists is optional and could be removed.
    if you include this to page.php, the if(is_page()) could also be removed.

    put the code into the predefined div instead of the usual <img src="blablabla" />
    in the above example, all you/your client needs to do is to make sure there is a picture with the file name 'picture-chef-hugo-the-great.jpg' in the /images folder of the theme, if they want it to show on the page 'Chef Hugo the Great'
    (check the usage of page slugs)
    and someone must be able to upload an image to a given location.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.