WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] multiple static page in one static page (22 posts)

  1. soriso
    Member
    Posted 2 years ago #

    Hi,

    I need some help, I need to show multiple (about, events & contact) static pages in one static page (home). The most that I have read are post related what I need is the pages itself. Also where do I make the changes in the index.php or page.php? Any help would be appreciated.

    Thanks!

  2. vtxyzzy
    Member
    Posted 2 years ago #

    You should create a Child theme to make your changes. If you do not, all of your changes will be lost if you update your theme.

    You will not make changes in index.php or page.php. Instead, you will create a new template which contains 3 Loops. Each Loop will retrieve one of the 3 other pages that you want to display.

    The exact way to do this will depend on your theme. In general, you can start with a copy of page.php renamed to something like frontpage.php, and modify it to be your template by adding the following code at the top:

    <?php
    /*
    Template Name: Front Page
    */
    ?>

    Then add the code for the 3 loops to replace the original loop.

  3. soriso
    Member
    Posted 2 years ago #

    Thanks! I will try and let you know how it goes.

  4. soriso
    Member
    Posted 2 years ago #

    Ok, I created a child theme and inside are two files style.css & frontpage.php. I place the loops for the pages I wanted to show (about & events). But its still not working. :(

    Can you please help me?

    This is whats inside my frontpage.php

    <?php
    /*
    Template Name: Front Page
    */
    ?>
    
    get_header(); ?>
    
    		<div id="primary">
    			<div id="content" class="narrowcolumn">
    
    	<?php
        $about = get_posts('page_id=12');
        foreach($about as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    	<?php
        $events = get_posts('page_id=25');
        foreach($events as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    		</div><!-- #primary -->
    
    <?php get_footer(); ?>
  5. vtxyzzy
    Member
    Posted 2 years ago #

    Did you create a new blank page for your front page and assign 'Front Page' as the template?

    If so, and it didn't work, please post a link to your site where the page can be seen.

  6. soriso
    Member
    Posted 2 years ago #

    Hmm no, I didn't create one. Sorry this might sound stupid but how do I do that? Do I create it as part of the .php files or just Page > Add New Page ? And how can I choose a template for this?

    Also here's my site: http://kiwirootsmusic.com/

    Thanks again!

  7. vtxyzzy
    Member
    Posted 2 years ago #

    Use Pages->Add New. Put in a title, leave the content empty. Under 'Page Attributes' in the right column, find the dropdown under 'Template' and select 'Front Page'. Click 'Publish'.

    Next, go to Admin->Settings->Reading and click 'A static page'. Choose your new Page in the dropdown and click 'Save Changes'.

  8. soriso
    Member
    Posted 2 years ago #

    I can't find the Front Page template in the Template dropdown. How do I make it show up? Question though, when I created the frontpage.php file I placed it under the Child Theme is that correct?

    Sorry I have so many questions. Thanks for being patient.

  9. vtxyzzy
    Member
    Posted 2 years ago #

    frontpage.php does go in the Child theme folder. Did you activate the child theme?

  10. soriso
    Member
    Posted 2 years ago #

    Ok, I hope I'm getting close I activated the child theme and was able to select frontpage template. But now the problem is there's nothing to show so my site looks like this http://kiwirootsmusic.com

    On second thought I think I'm not getting close :(

  11. vtxyzzy
    Member
    Posted 2 years ago #

    OK - you have a small error in the template. Change this:

    get_header(); ?>

    to this:

    <?php get_header(); ?>
  12. vtxyzzy
    Member
    Posted 2 years ago #

  13. soriso
    Member
    Posted 2 years ago #

    Ok I now have the blank front page in my home page. But I guess I still have a problem in showing the 2 static pages I have in the front page. Is there something wrong with the loop I have that's it's not showing anything?

    Thanks!!!

  14. vtxyzzy
    Member
    Posted 2 years ago #

    Two problems (assuming the code you first posted is still what you are using):

    First, you need to add the post_type argument to get_posts like this:

    $about = get_posts('page_id=1114&post_type=page');

    Second, you are missing a closing div for #content. It needs to go just above the closing div for #primary:

    </div><!-- #content -->
    		</div><!-- #primary -->
  15. soriso
    Member
    Posted 2 years ago #

    Wow!!! it's working!!! Thank you so much vtxyzzy.

    Now I just have to figure out how to align it :)

  16. soriso
    Member
    Posted 2 years ago #

    Another question, how can I include the sidebar without placing the loop below it?

    <?php get_sidebar('right'); ?>

    This is what I have right now... http://www.kiwirootsmusic.com

    <?php
    /*
    Template Name: Front Page
    */
    ?>
    
    <?php get_header(); ?>
    <?php get_sidebar('right'); ?>
    
    		<div id="primary">
    			<div id="content" class="narrowcolumn">
    
    	<?php
        $about = get_posts('page_id=12&post_type=page');
        foreach($about as $post) :
        setup_postdata($post);
        ?>
  17. vtxyzzy
    Member
    Posted 2 years ago #

    How you do that depends on your theme. Model it after page.php or single.php.

  18. soriso
    Member
    Posted 2 years ago #

    Yea, I tried inserting it in the page.php and removing it from the frontpage.php. What it did was it inserted the sidebar to all pages but the content of the pages are all showing after the sidebar. How do I make it show in the frontpage? Thanks again!

  19. vtxyzzy
    Member
    Posted 2 years ago #

    Do NOT change page.php!!! Look at and model your frontpage.php after it.

  20. DIY Bazaar
    Member
    Posted 1 year ago #

    Hey guys!

    I've installed the oxygen theme for my website (a diy online magazine). My problem is that I have 6 main topics, with several subcategories. For each main topic I will like to have a different menu. For example, when you click the home decor section displayed in the top bar menu, you'll see a side bar with living rooms, bedrooms, bathrooms, a.s.o. For DIY projects, the side menu displays diy for kids, fashion diy, handmade e.s.o.

    PS: oxygen theme allowed to create 3 different menus (top, side and bottom). I know how to do all this. The thing is that all bar menus are the same for all 6 main topics and I want a common top bar, but different side bar. The bottom one is not important.

    Thanks for your support!

    All the best!

  21. vtxyzzy
    Member
    Posted 1 year ago #

    You should start a new thread for this topic.

  22. DIY Bazaar
    Member
    Posted 1 year ago #

    I did that! Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic