Forums › Forums › Search & Filter Pro › Custom Template
Tagged: custom template
- This topic has 2 replies, 2 voices, and was last updated 6 years, 5 months ago by Anonymous.
-
Anonymous(Private) June 28, 2018 at 5:10 pm #181547
I tried to create a custom template by copying one of my per-existing templates and running through the WP loop. I looked at the documentation to verify that I was running the correct query. Unfortunately it just loads all of the posts without any filtering whatsoever. I just need more direction on how to make this work correctly.
`<?php $args = array(‘post_type’ => ‘post’, ‘search_filter_id’ => 49); $search_results = new WP_Query( $args ); if ($search_results->have_posts()) : while ( $search_results->have_posts() ) : $search_results->the_post();?>
<article class=”recent__post”>
<div class=”recent__post-thumbnail” style=”background-image: url(‘<?php the_post_thumbnail_url( ‘medium_large’ ); ?>’)” ></div>
<div class=”recent__post-info”>
<div class=”recent__post-meta”>
<?php print_formatted_topic( ‘recent__post-taxonomy’ ) ?>
<time class=”recent__post-time”>/ <?php the_time(‘M jS, Y’); ?></time>
</div>
<h3 class=”recent__post-heading”>
<a href=”<?php the_permalink(); ?>”>
<?php the_title(); ?>
</a>
</h3>
<p class=”recent__post-exerpt”>
<?php echo get_the_excerpt(); ?>
</p>
</div>
</article>
<?php endwhile;?>
<?php endif; wp_reset_postdata();?>`
My primary objective is to have finely tuned markup in the results. I want the post result structure to match the markup above exactly. Thanks for any help you may be able to provide!
Trevor(Private) June 28, 2018 at 6:04 pm #181556It might be easier to use our Shortcode Display results method, copy the results.php file as instructed to your child theme folder, find the bit in that code that matches your ‘while’ loop and replace our code with yours (not all of yours will be needed):
https://searchandfilter.com/documentation/search-results/using-a-shortcode/
-
AuthorPosts