-
Search Results
-
Hi,
Im unable to get ACF Post Object fields to output in to the results, any idea’s on the correct format?<?php while ($query->have_posts()) { $query->the_post(); ?> <tr> <td> <?php $post_object = get_field('customer'); if( $post_object ): // override $post $post = $post_object; setup_postdata( $post ); ?> <?php the_title(); ?> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> <?php endif; ?> </td> <td><?php the_date(); ?></td> <td><?php echo the_ID(); ?></td> <td><?php echo the_field('reg_no'); ?></td> </tr> <?php } ?>At the moment “the_title” inside the post object, outputs the title of the search result, not the title thats defined inside the search result post.
Hopefully that makes sense, and hopefully its just a syntax issue.
Thanks,
MikeHi!
Great plugin, but I’m having a problem right now.
Everything is working with a search box and filters, but when I use (in this case) the infinite scroll option, every post that loads gets a changed permalink.The code I use within the ‘while’ loop for a post is this:
<div class="item route"> <div class="item-image"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('formatted'); ?> <div class="item-image-overlay"></div> </a> <h3 class="item-title"><?php the_title(); ?></h3> </div> <!--<div class="item-price"></div> <div class="price-tag"> <span>vanaf</span> <span class="price">€ 59,<sup>50</sup></span> <span>p.p.</span> </div>--> <div class="item-content"> <h4><?php echo $arrCity; ?><?php echo $arrProvince; ?><?php echo $arrRegion; ?></h4> <?php the_field('korte_omschrijving'); ?> </div> <div class="item-more"> <a href="<?php echo $permalink; ?>" class="btn btn-block ajax" data-url="<?php the_permalink(); ?>" data-title="<?php the_title(); ?>">Bekijk route <i class="fa fa-angle-right" aria-hidden="true"></i></a> </div> </div>The problem is that ‘the_permalink()’ is changed.
A piece of code is added by the plugin, e.g. permalink/?sf_paged=2.
I really need to get rid of the added code because I use Ajax to load the content of that post in a modal.Hopefully my problem is clear enough.
Thanks in advance!Alex
Topic: Custom Query and template
Hi,
Just bought and read the docs but i’m not following here.
This is a piece from one template file in my theme:
<section id="events-lijst"> <?php // the query $options = array( 'post_type' => 'event', 'posts_per_page' => 20, 'order' => 'ASC', 'meta_key' => 'taal', 'meta_value' => 'Nederlands' ); $query = new WP_Query( $options ); ?> <?php if ( $query->have_posts() ) : ?> <div class="container"> <div class="eventrow"> <?php while ( $query->have_posts() ) : $query->the_post(); ?> <div class="panel panel-default"> <div class="panel-heading"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> </div> <div class="event-foto-sectie"> <?php $uitgelichte_afbeelding = get_field( 'uitgelichte_afbeelding' ); ?> <?php if ( $uitgelichte_afbeelding ) { ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo $uitgelichte_afbeelding['url']; ?>" class="event-featured-img" alt="<?php echo $uitgelichte_afbeelding['alt']; ?>" /></a> <?php } ?> </div> <div class="panel-body"> <?php $dateformatstring = "l d F, Y"; $unixtimestamp = strtotime(get_field('datum')); ?> <p><strong>Datum: </strong> <?php echo date_i18n($dateformatstring, $unixtimestamp); ?><br/><strong>Locatie: </strong><?php the_field( 'locatie' ); ?></p> <span class="eventuitleg"><?php the_excerpt(); ?></span> <p class="bekijkevent"><strong><a href="<?php the_permalink(); ?>">Bekijk dit evenement</a> >></strong></p> </div> </div> <?php endwhile; ?> </div> </div> <?php wp_reset_postdata(); ?> <?php else : ?> <section class="section-padding"> <div class="container"> <div class="row-centered"> <div class="col-md-12 col-centered"> <strong>Sorry, geen enkel event geprogrammeerd op dit ogenblik...</strong> </div> </div> </div> </section> <?php endif; ?> </section><!-- event lijst -->I want to put a row at the top where my query underneath is filterd on custom fields (using ACF)
Hi,
How could I order results by ACF type of field “powierzchnia”?<?php while ($query->have_posts()) { $query->the_post(); ?> <a href="<?php the_permalink(); ?>"> <ul> <li><?php the_title(); ?></li> <?php if (get_field ('powierzchnia') ) : ?> <li><span><?php echo the_field ('powierzchnia'); ?></span> m<sup>2</sup></li> <?php endif; ?>Regards