chrisguitarguy / pjaxy

A library to make using PJAX in your WordPress themes a little easier.
27 stars 2 forks source link

Load Homepage with PJAX #2

Open jorditost opened 12 years ago

jorditost commented 12 years ago

Hi Chris,

It seems that the homepage is always loaded by reloading the whole page, but I'd be interesting to load it with PJAX.

I have inside the folder 'pjax-templates' also a home.php with its content.

Is there a way to fix?

Thanks!

chrisguitarguy commented 12 years ago

Can you post the content of your home.php pjax template?

jorditost commented 12 years ago

Here the code:

<?php get_pjaxy_page_info(); ?>

<title><?php bloginfo('name'); echo ' | '; bloginfo('description'); ?></title>

<?php 
    $page = get_page_by_path('home');
    if ($page) :
?>  
    <div id="page-home" class="content inside" data-section="home">
        <h1 id="home-claim"><?php echo __($page->post_excerpt); ?></h1>

        <div class="entry">
            <?php echo format_content($page->post_content); ?>
        </div>
    </div><!-- .content -->

    <div id="home-gallery">
        <ul>
            <?php echo get_post_gallery_by_ID($page->ID, 'full', false, 'li', true); ?>
        </ul>
    <?php
        global $isMobile;
        if ( !$isMobile ) { ?>
        <div id="gallery-drag-help"></div>
    <?php } ?>
    </div><!-- #intro-gallery -->

<?php endif; ?>
jorditost commented 12 years ago

Hi Chris,

I've been testing and it seems that the home.php template is not working at all. In pjax.jquery.js, PJAX is getting the title and other parameters correctly, but no content is read. Look at this piece of code (line 200). With home.php it reloads the page and returns:

    if (!container.contents) {
      window.location = container.url
      return
    }

Just by changing the name of the template from home.php to index.php, it works properly.

chrisguitarguy commented 12 years ago

Yes, there's an issue with it not finding the home page.

Is this meant to be a static home page? Eg. in Options > Read "Front Page Shows" is set to a static page?

jorditost commented 12 years ago

No, it's not statically defined. It loads the page I query directly in home.php.

El 03/08/2012, a las 18:36, Christopher Davisreply@reply.github.com escribió:

Yes, there's an issue with it not finding the home page.

Is this meant to be a static home page? Eg. in Options > Read "Front Page Shows" is set to a static page?


Reply to this email directly or view it on GitHub: https://github.com/chrisguitarguy/pjaxy/issues/2#issuecomment-7487805

chrisguitarguy commented 12 years ago

I'm confused what you're trying to do, but Pjaxy will follow the WordPress template hierarchy. Without seeing your entire theme, I can't help you.

In other words: if this is the home page, WordPress will load home.php if you have the front page set to be a posts page. Otherwise, it's going to lood for front-page.php, then page templates, then page.php and finally back to index.php.

ChaplinWang commented 7 years ago

found one issue in pjaxy.js, the init call to pjax does not match current pjax init signature.

I have created a pull request to fix this: https://github.com/chrisguitarguy/pjaxy/pull/4