SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Brazil
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Add a page to another page

    Well guys, I was wondering how can I add a page to another.

    Example: The "Contact Us" of my company will be based on the page "Service" from that bank (Example).

    I wonder how I can create a separate page in the format of the example image (contact-content.php) and include in page.php, but with the condition if and only if it is the page "Contact Us".

    I started writing the code but could not finish it:

    This is my page.php
    Code:
    <?php get_header();?><!--AQUI FICA O HEADER-->
    
    
    
        <div id="content"><!--INICIO DIV CONTENT-->
    
    
            <div id="page_content"><!--INICIO DIV PAGE_CONTENT-->
    
                <?php if (have_posts()): while (have_posts()) : the_post();?>
    
    
                    <span class="titulo"><?php the_title();?></span>
                    <?php the_content();?>
    
    
                <?php endwhile; else:?>
                <?php endif;?>
    
            </div><!--FIM DIV SINGLE_CONTENT-->
    
    
        </div><!--FIM DIV CONTENT-->
    I hope that you'd understand,
    now,
    thank you.

    Edit: Actually I'm just going to create the contents of the "Contact Us" and want it to be included if and only if the page in question is itself

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    You could do a few things:
    1- make a partial file called contactinfo.php or whatever.
    in page.php you can try
    PHP Code:
    <?php if (have_posts()): while (have_posts()) : the_post();?>
     <span class="titulo"><?php the_title();?></span>
       <?php if (is_page("Contact Us"){
           include(
    "contactinfo.php"); }
           
    the_content();?>
     <?php endwhile; else:?>
    <?php 
    endif;?>
    2, you can make a seperate file that contains everything: header, service stuff, footer. Put that file in your theme folder. The first lines of the file need to be:
    PHP Code:
    <?php
    /*
     *Template Name: Whatever-you-want 
     */
    ?>
    Make a new page, on the right you should see a page template drop down box, choose yours.
    Ryan B | My Blog | Twitter

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Brazil
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks @rguy84.
    I got it!

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Brazil
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ..but, If I want add more specific pages. How code would like?

    Code:
    <?php if (have_posts()): while (have_posts()) : the_post();?>
     <span class="titulo"><?php the_title();?></span>
       <?php if (is_page("Contact Us"){
           include("contactinfo.php"); }
    
       <?php if (is_page("Other Page"){
           include("otherpage.php"); }
    
       <?php if (is_page("Another Page"){
           include("anotherpage.php"); }
    
           the_content();?>
     <?php endwhile; else:?>
    <?php endif;?>
    Like that? ^

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Brazil
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone? :S

  6. #6
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crf_h0m3r View Post
    ..but, If I want add more specific pages. How code would like?

    Code:
    <?php if (have_posts()): while (have_posts()) : the_post();?>
     <span class="titulo"><?php the_title();?></span>
       <?php if (is_page("Contact Us"){
           include("contactinfo.php"); }
    
       <?php if (is_page("Other Page"){
           include("otherpage.php"); }
    
       <?php if (is_page("Another Page"){
           include("anotherpage.php"); }
    
           the_content();?>
     <?php endwhile; else:?>
    <?php endif;?>
    Like that? ^
    Hey friend, Is this method is working?

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Brazil
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ShinoRex, I guess not. That's why I want to know how to do.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •