lundi 5 octobre 2015

ACF Repeater is not working on home page, same loop works fine on interior pages. Have tried several methods

So basically I'm trying to run a loop of /downloads/ (using Easy Digital Downloads) on my homepage. I'm attaching custom fields to each album and trying to loop through that separately. This has been way more difficult than I imagined. I tried several different looping methods, some have worked better than others. My current solution is so close.

I've tried different resets, using and not using Global $post, I originally was trying to use the Relationship or Post Object field, which I'd still like to do. I swapped it for just straight custom field data thinking that would solve it but still not working.

I recently pasted the same code in the single-download.php and it worked fine. I adjusted the Reading settings in WP back and forth, reset permalinks. Really confused whats holding this code up on the homepage?

Here is my current code:

<ul class="img-grid-4" id="releases">

    <?php //global $post;
    $args = array(
        'post_type'        => 'download',
        'posts_per_page'   => -1,
        'cat'               => -8,
        'order'            => 'ASC',
        'paged' => ( get_query_var('page') ? get_query_var('page') : 1 ),
    );
    $custom_posts = new WP_Query($args);
    if ($custom_posts->have_posts()) :
        while( $custom_posts->have_posts()) :
            $custom_posts->the_post(); ?>


    <li>
        <a class="hook" href="<?php the_permalink(); ?>">
            <h5><?php the_title(); ?></h5>
            <?php if ( has_post_thumbnail() ) {
                the_post_thumbnail('full', array('class' => 'cover'));
            }  ?>
        </a>
        <section class="info">
            <h1><?php the_title(); ?></h1>
            <span class="close"><i class="icon-close"></i></span>
            <h6 class="price">Singles - $0.89 | Album - <?php echo get_post_meta( get_the_ID(), 'edd_price', true ); ?></h6>


    <?php if( have_rows('release_singles') ): ?>

        <ul class="tracks">
        <?php while( have_rows('release_singles') ): the_row(); 
            // vars
            $title = get_sub_field('title');
            $id = get_sub_field('cart_id');
            $link = get_sub_field('sample');
            ?>

            <li>
                <a href="" data-src="<?php echo $link; ?>" class="sm2_link">
                    <?php echo $title; ?>
                </a>
                <?php echo do_shortcode('[purchase_link class="button icon-cart" id="'. $id .'"]'); ?>       
            </li>

        <?php endwhile; ?>

        </ul>

    <?php endif; ?>



            <?php the_content(); ?>

            <a class="button" href="<?php the_permalink(); ?>">See Page</a>

            <?php echo do_shortcode('[purchase_link class="button"]'); ?>

            <footer class="entry-footer">
                <?php szymanskimusic_entry_footer(); ?>
            </footer><!-- .entry-footer -->
        </section>

    </li>

<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</ul>

Link to the demo site is here: http://ift.tt/1FSzq3S

If you click on the first album (orange with face on it) a modal pops up with the album info, plus a list of the repeater fields. The title and Cart buttons are correct, but clicking on the song link loads and plays the same mp3 for each of the list items.

If you click the See Page button at the bottom, you'll go to the single page, which has the same loop, and is working fine.

Code is also here: http://ift.tt/1LbFnF8

front-page-2 is currently what I'm using, and methods-tried.php are the various loop's I've tried to use.

$('#releases > li').on('click', '.hook', function(e){
        var $this = $(this);

        $this.removeAttr('href').parent().addClass('live');

        var $list = $this.siblings('.info').find('li');
        $list.each( function(){
            var $src = $(this).children('.sm2_link').data('src');
            $('.sm2_link').attr( 'href', $src );
        })
        soundManager.reboot();
        e.preventDefault();
    });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire