Support » Themes and Templates » pages (not posts). conditional. insert image

  • rwilliams1961

    (@rwilliams1961)


    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.

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

    (@nsathees)

    use the is_page() template tag.

    more info here . . .

    http://codex.wordpress.org/Conditional_Tags

    Thread Starter rwilliams1961

    (@rwilliams1961)

    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.

    Michael

    (@alchymyth)

    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:

    <?php
    if(is_page()) {
    $page_slug=$post->post_name;
    $image='picture-'.$page_slug.'.jpg';
    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘pages (not posts). conditional. insert image’ is closed to new replies.