• Hey,

    I’m having some problems with the output of the repeater fields.

    this is the origional query i want to make repeatable with Ajax load more:

    <?php
                $type = 'event';
                $args= array(
                    'post_type'             => $type,
                    'posts_per_page'        => 3,
                  );
    
                $my_query = null;
                $my_query = new WP_Query($args);
                if( $my_query->have_posts()) {
                while ($my_query->have_posts()) : $my_query->the_post(); ?>
                <?php global $post; ?>
    			<?php $image_id = get_post_thumbnail_id(); ?>
                <?php $image_url = wp_get_attachment_image_src($image_id,'large', true); ?>
                <?php $check= get_post_meta($post->ID, 'youtube-video-code', true); ?>
                <?php if (!empty($check)) { ?>
                <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="event-block">
                    <div class="small-12 medium-4 large-4 columns">
                    	<?php
    					$url = $check;
    					parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
    					?>
                        <div class="post-image" style="background-image: url(http://img.youtube.com/vi/<?php echo $my_array_of_vars['v']; ?>/0.jpg);">
                        </div>
                        <div class="post-info">
                            <div class="row">
                                <div class="small-12 columns">
                                    <h3><?php the_title(); ?></h3>
                                    <?php $num = get_post_custom_values('aantal-deelnemers-per-evenement', get_the_ID( $post->ID )); ?>
                                    <p><?php echo $num[0]; ?> PEOPLE SANG FOR THE CLIMATE</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </a>
                <?php } else { ?>
                 <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="event-block">
                     <div class="small-12 medium-4 large-4 columns">
                        <div class="post-image" style="background: #16e19f;">
                            <div class="date-wrap">
                            	<?php $temp = get_template_directory_uri(); ?>
                                <?php echo do_shortcode('[event]<img src="'. $temp .'/img/kalender-icon.svg" width="10px" height="11px" alt=""/><div class="date-wrap-inner"><span class="day">#d</span><span class="month">#F</span></div><span class="year">#Y</span>[/event]'); ?>
                            </div>
                        </div>
                        <div class="post-info">
                            <div class="row">
                                <div class="small-12 columns">
                                    <h3><?php the_title(); ?></h3>
                                    <p><?php echo do_shortcode('[event]#d.#m.#Y &mdash; STARTS AT #h:#m[/event]'); ?></p>
                                </div>
                            </div>
                        </div>
                     </div>
                 </a>
                <?php } ?>
                <?php endwhile; } wp_reset_query(); ?>

    There are 2 different views that i impletented in the custom repeaters:
    This one is the first:

    <?php global $post; ?>
    <?php if (!empty($check)) { ?>
    <?php $check= get_post_meta($post->ID, 'youtube-video-code', true); ?>
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="event-block">
                    <div class="small-12 medium-4 large-4 columns">
                    	<?php
    					$url = $check;
    					parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
    					?>
                        <div class="post-image" style="background-image: url(http://img.youtube.com/vi/<?php echo $my_array_of_vars['v']; ?>/0.jpg);">
                        </div>
                        <div class="post-info">
                            <div class="row">
                                <div class="small-12 columns">
                                    <h3><?php the_title(); ?></h3>
                                    <?php $num = get_post_custom_values('aantal-deelnemers-per-evenement', get_the_ID( $post->ID )); ?>
                                    <p><?php echo $num[0]; ?> PEOPLE SANG FOR THE CLIMATE</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </a
    <?php } ?>

    This is the shortcode i used:
    <?php echo do_shortcode('[ajax_load_more post_type="event" posts_per_page="3" scroll="true"]'); ?>

    And this is the second:
    <?php echo do_shortcode('[ajax_load_more repeater="template_1" post_type="event" posts_per_page="3" max_pages="0"]'); ?>

    Everything works perfect with the first query but both of them output fields but always the same value. How is this possible?
    Do i need to write a extra query inside the repeater fields or is it a problem with displaying fields of the wp-event plugin?

    Little bit stuck here 🙂

    Thanks in advance!

    https://wordpress.org/plugins/ajax-load-more/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Having a hard time understanding where things are going wrong here…
    Can you post both your repeater templates?

    Thread Starter jannik.dolferus

    (@jannikdolferus)

    The first example is posted above.
    the second one is the other piece of the first example :

    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="event-block">
                     <div class="small-12 medium-4 large-4 columns">
                        <div class="post-image" style="background: #16e19f;">
                            <div class="date-wrap">
                            	<?php $temp = get_template_directory_uri(); ?>
                                <?php echo do_shortcode('[event]<img src="'. $temp .'/img/kalender-icon.svg" width="10px" height="11px" alt=""/><div class="date-wrap-inner"><span class="day">#d</span><span class="month">#F</span></div><span class="year">#Y</span>[/event]'); ?>
                            </div>
                        </div>
                        <div class="post-info">
                            <div class="row">
                                <div class="small-12 columns">
                                    <h3><?php the_title(); ?></h3>
                                    <p><?php echo do_shortcode('[event]#d.#m.#Y &mdash; STARTS AT #h:#m[/event]'); ?></p>
                                </div>
                            </div>
                        </div>
                     </div>
                 </a>

    i Guees it’s a problem that the shortcode inside the repeater can’t figure out the id after it loops once.

    Plugin Author Darren Cooney

    (@dcooney)

    Where is the shortcode requesting the ID?

    Is this your complete repeater template?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem getting values. value is allways the same’ is closed to new replies.