Forum Replies Created
-
AuthorPosts
-
agelfandMember
The plot thickens! I moved the Post Object code outside the main loop. NOW I see the actual post objects selected in the back end through ACF, but they aren't being outputted in the page where I want them. Still, making progress. Can someone please help me along here? I need this post object to echo code before the end of the entry content...thank you.
<?php remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop add_action( 'genesis_loop', 'custom_do_loop' ); // Add custom loop function custom_do_loop() { while(have_posts()) : the_post(); // Intro Text (from page content) echo '<div class="page hentry entry">'; echo '<h1 class="entry-title">'. the_title() .'</h1>'; echo '<div class="entry-content">' . the_content() .'</div>'; $bookinglink = get_field('booking_url'); echo '<a class="button" href="'.$bookinglink.'" >'; $btntext = get_field('booking_button_text'); if ($btntext == '') { echo 'Book '; echo the_title(); } else { echo $btntext; } echo '</a>'; $video1 = get_field( 'video_one'); if( isset($video1) && $video1 != '' ){ echo '<h4>Video Gallery</h4>'; echo '<div class="one-third first">'; echo $video1; echo '</div>'; } $video2 = get_field( 'video_two'); if( isset($video2) && $video2 != '' ){ echo '<div class="one-third">'; $video2 = get_field( 'video_two'); echo $video2; echo '</div>'; } $video3 = get_field( 'video_three'); if( isset($video3) && $video3 != '' ){ echo '<div class="one-third">'; $video3 = get_field( 'video_three'); echo $video3; echo '</div>'; } echo '<div class="clear"></div>'; $gallery_id = get_field('nextgen_gallery_id'); if( isset($gallery_id) && $gallery_id != '' ){ echo '<h4>Image Gallery</h4>'; echo "<div class=\"post-gallery\">"; // echo nggShowGallery( $gallery_id ); // Display the gallery echo do_shortcode( $gallery_id ); echo "</div><div class='clear'></div>"; } echo '<div class="post"><h4>Topics</h4>'; endwhile; } //HERE IS THE PART I AM HAVING TROUBLE WITH // always good to see exactly what you are working with $posts = get_field('you_might_also_like'); // always good to see exactly what you are working with if( $posts ): foreach( $posts as $post): // variable must be called $post (IMPORTANT) setup_postdata($post); ?> <div class="block"> <div class="fix"></div> <h2 class="cufon"><?php the_title(); ?></h2> <?php the_excerpt(); ?> <span class="more"><a href="<?php the_permalink(); ?>"><?php _e('More Info', 'woothemes') ?></a></span> </div> <?php endforeach; ?> <div class="fix"></div> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly endif; echo '</div><!-- end .entry-content -->'; echo '</div><!-- end .page .hentry .entry -->'; /** Remove Post Info */ remove_action('genesis_before_post_content','genesis_post_info'); remove_action('genesis_after_post_content','genesis_post_meta'); genesis();
agelfandMemberHi, it's me again. 🙂
I placed my ACF fields in a template, to see if things would work inside a custom loop I crreated. Everything works except the POST OBJECT at the end. Can someone at least look at my code and see if there is an obvious fumble on my part? As with my custom function in functions.php, even though the $posts array with my custom data is in there, I can't get it to echo out. It just runs through however many post objects there are and echoes the title of the current post. This is a "you may also like" section.
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop add_action( 'genesis_loop', 'custom_do_loop' ); // Add custom loop function custom_do_loop() { while(have_posts()) : the_post(); // Intro Text (from page content) echo '<div class="page hentry entry">'; echo '<h1 class="entry-title">'. the_title() .'</h1>'; echo '<div class="entry-content">' . the_content() .'</div>'; $bookinglink = get_field('booking_url'); echo '<a href="'.$bookinglink.'">'; $btntext = get_field('booking_button_text'); if ($btntext == '') { echo 'Book '; echo the_title(); } else { echo $btntext; } echo '</a>'; $video1 = get_field( 'video_one'); if( isset($video1) && $video1 != '' ){ echo '<h4>Video Gallery</h4>'; echo '<div class="one-third first">'; echo $video1; echo '</div>'; } $video2 = get_field( 'video_two'); if( isset($video2) && $video2 != '' ){ echo '<div class="one-third">'; $video2 = get_field( 'video_two'); echo $video2; echo '</div>'; } $video3 = get_field( 'video_three'); if( isset($video3) && $video3 != '' ){ echo '<div class="one-third">'; $video3 = get_field( 'video_three'); echo $video3; echo '</div>'; } echo '<div class="clear"></div>'; $gallery_id = get_field('nextgen_gallery_id'); if( isset($gallery_id) && $gallery_id != '' ){ echo '<h4>Image Gallery</h4>'; echo "<div class=\"post-gallery\">"; // echo nggShowGallery( $gallery_id ); // Display the gallery echo do_shortcode( $gallery_id ); echo "</div><div class='clear'></div>"; } echo '<div class="post"><h4>Topics</h4>'; //HERE IS THE PART I AM HAVING TROUBLE WITH // always good to see exactly what you are working with $posts = get_field('you_might_also_like'); // always good to see exactly what you are working with if( $posts ): foreach( $posts as $post): // variable must be called $post (IMPORTANT) setup_postdata($post); ?> <div class="block"> <div class="fix"></div> <h2 class="cufon"><?php the_title(); ?></h2> <?php the_excerpt(); ?> <span class="more"><a>"><?php _e('More Info', 'woothemes') ?></a></span> </div> <?php endforeach; ?> <div class="fix"></div> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly endif; endwhile; echo '</div><!-- end .entry-content -->'; echo '</div><!-- end .page .hentry .entry -->'; } /** Remove Post Info */ remove_action('genesis_before_post_content','genesis_post_info'); remove_action('genesis_after_post_content','genesis_post_meta'); genesis();
agelfandMemberWell, can anyone speak to the general issue of having secondary loop queries in genesis? It's frustrating that this widely used plugin doesn't have much in the way of documentation for use with Genesis. I would have guess the two are widely used together. Of course, I've been wrong before! 🙂
https://gist.github.com/anonymous/232ad6bebf6b3a1b3e6c2e5093e1be95
-
AuthorPosts