WordPress.org

Ready to get started?Download WordPress

Forums

Template + Front Page + Gallery = No Images? (7 posts)

  1. rpflorence
    Member
    Posted 4 years ago #

    I have done the following:

    Template: Home
    
    Page:
      name: home
      slug: home
      template: home
    
    Permalinks: %postname%
    
    Reading->Front Page: home

    On my home page I've got text and a gallery of images.

    Everything works fine if I visit the page directly with:
    http://site/home/

    But if I visit the root and WP renders home as the front page the gallery doesn't display, though the text still does.
    http://site/

    I am getting the page like so:

    <?php
    /*
    Template Name: Home
    */
    $page = Array("about" => 2);  // will be bringing content from other pages
    $home = get_page($pages['about']);
    
    ?>

    And then rendering it:
    <?php echo apply_filters('the_content', $home->post_content); ?>

    To remedy the problem I tried a quick bandaid approach of checking the get variables for page_id--if absent, forward to /home and the images work great. That worked with permalinks set to default. Now that I've got permalinks enabled, the get array is always empty!

    So I've got a bandaid approach right now, I dropped this at the top of my Home template.

    if($_SERVER['REQUEST_URI'] == '/') {
    	header('location: /home/');
    }

    So my first hope is to get it to work w/o having a redirect. Seems like it's something similar to apply_filters. If not possible, I'm totally fine with checking the request uri and then forwarding to /home

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

  3. rpflorence
    Member
    Posted 4 years ago #

    Thanks for the reply.

    I am using a static front page. That's the root of the problem.

    When it renders the static front page it doesn't display the gallery in the page content. If I visit the page directly then it displays everything correctly.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    What gallery? Is this a group of images that were uploaded whilst editing that page?

  5. rpflorence
    Member
    Posted 4 years ago #

    Yes, default wordpress installation 2.9. Edit a page, upload some files, click "insert gallery." No plugins.

  6. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Yes - but did you upload the images whilst working on this page - your front page?

  7. mathanagopalan
    Member
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic