WordPress template trick for page

Discussion in 'WordPress' started by Zhu, Nov 26, 2007.

  1. #1
    Hi folks,

    I'm currently working on my blog design and more specifically on pages.

    I have a series of pages (like "about me", "contact me" etc.). For the "contact me", instead of writing a post, I'd like to display a jpg image.

    I don't want this image to be display on the usual light blue post background (see my blog below...). I want it in lieu of the contentmiddle.

    So I make a graphic in Photoshop, the same size as my contentmiddle (like 540 x 600 px) and I'd like to replace the whole content middle by this graphic.

    I added the image in the post meanwhile, so you can check it out: Contact Me Page

    I need the image without the usual post background.

    But now I'm stuck!

    Do I have to create a new page template, like contactme.php?

    Sorry, it's hard to explain, but if you could point me to the right direction, I'd appreciate!

    Thanks
     
    Zhu, Nov 26, 2007 IP
  2. Houdy

    Houdy Peon

    Messages:
    267
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can make a new custom page template. You can make as many as you want, copy the current page.php from your themes directory edit it, save it as a different name (aboutpage.php). Upload in the themes directory. Then when you create or edit a page it should appear in the drop down box on the right under page template.

    More here with a video:How To Create A Custom WordPress Page Template
     
    Houdy, Nov 26, 2007 IP
  3. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thanks for the info. I'm still a bit confused about make a new php page from the scratch, but I guess I need to watch the video a second time !

    I must admit I'm fairly new with php (but fine with CSS), so I still can't find the way to link an image...
     
    Zhu, Nov 26, 2007 IP
  4. Lastbutnotleast

    Lastbutnotleast Peon

    Messages:
    2,612
    Likes Received:
    105
    Best Answers:
    0
    Trophy Points:
    0
    #4
    1/ Great blog dear Juliette!

    2/ Thanks for the link Houdy ;)
     
    Lastbutnotleast, Nov 26, 2007 IP
  5. MarRome

    MarRome Peon

    Messages:
    865
    Likes Received:
    92
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hello Zhuli

    This should be fairly simple.

    Take the page template your using for the contact page rename it and use the new template for your contact page and change the css thats associated with your post area.

    Best of luck
     
    MarRome, Nov 27, 2007 IP
  6. Houdy

    Houdy Peon

    Messages:
    267
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #6
    As MarRome said just copy the current page.php and rename it. If you want nothing different other than to include an image just above the text of the page, place the code for the image just above this:

    <?php if(have_posts()): ?><?php
     
    Houdy, Nov 27, 2007 IP
  7. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Thanks guys! I'm finishing the graphic and will experiment with my template this week. I'll let you know how it went!
     
    Zhu, Nov 27, 2007 IP
  8. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #8
    Okay... I'm afraid I'm gonna have a few more questions!

    This is the beginning of my new contactme.php file I created (copy from page.php) :

    So far, so good. Now, I need to get rid of my usual post background (= middlecontent I think) to replace it with my image.

    I tried to replace <div id="contentmiddle"> with <div id="contactmetemplate"> and style the CSS. The image does display but it shifts to the left and messes up my blog (sidebars etc.).

    I may be doing things wrong...

    So:

    1) How can I override the current post template?
    2) How can I link to an image with php?

    Sorry about the questions, I'm very very new with php and it's still confusing to me, no matter how much I read about it!

    Thanks
     
    Zhu, Nov 28, 2007 IP
  9. Houdy

    Houdy Peon

    Messages:
    267
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You can just place the image directly into the file like this, take out or leave in what ever else you want. In the example below all that shows on this page is the header, footer sidebar and the image centered where the content would be. There may be a better way but this is pretty easy using plain html to add the image.


    
    <?php
    /*
    Template Name: Contact Template
    
    */
    ?>
    
    <?php get_header(); ?>
    
    
    	<div id="content_box">
    
    <div id="content" class="page">
    	
    		
    <p align="center"><img border="0" src="http://correresmidestino.com/wp-content/uploads/2007/11/contactmebg.jpg" ></p>
    
    		</div>
    
    		<?php get_sidebar(); ?>
    
    	</div>
    
    <?php get_footer(); ?>
    PHP:
    This is an example on a test blog with a different theme than yours, the code may differ than yours and the image is too big in this case. If this doesn't work post your whole regular page.php file for us to look at.

    Check It out here: http://www.esmartjob.com/new/test
     
    Houdy, Nov 28, 2007 IP
  10. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #10
    Hi Houdy and thanks you for your patience... which is about to be tested again! :D

    I tried a few things, but I always end up with template problems: either I get a syntax error, either I lose both of my sidebars etc.

    This is the original page.php I use with my them (non modified):

    The jpg image I'm trying to use as the background is the same width as my current contentmiddle, so it should be a problem... :confused:

    Once you show me once, I'd be able to learn and understand what I do wrong, but so far, I'm still stuck!

    Thanks!
     
    Zhu, Nov 29, 2007 IP
  11. Houdy

    Houdy Peon

    Messages:
    267
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Well try this:

    
    
    <?php
    /*
    Template Name: Contact Template
    
    */
    ?>
    
    
    <?php get_header(); ?>
    
    <div id="content">
    
    <?php include(TEMPLATEPATH."/l_sidebar.php");?>
    
    <div id="contentmiddle">
    
    <p align="center"><img border="0" src="http://correresmidestino.com/wp-content/uploads/2007/11/contactmebg.jpg" ></p>
    
    </div>
    
    <?php comments_template(); // Get wp-comments.php template ?>
    
    </div></div>
    
    <?php include(TEMPLATEPATH."/r_sidebar.php");?>
    
    </div>
    
    <?php get_footer(); ?>
    PHP:
     
    Houdy, Nov 29, 2007 IP
  12. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #12
    Phew, thank for your patience! I finally got it to work fine, and style it in the CSS: Contact me

    You've been very patient with me, thanks again ;-)
     
    Zhu, Nov 30, 2007 IP
  13. Houdy

    Houdy Peon

    Messages:
    267
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Your welcome! "If the women don't find ya handsome the should at least find ya handy!"
     
    Houdy, Nov 30, 2007 IP
    Zhu likes this.