-
AuthorSearch Results
-
September 4, 2019 at 8:44 pm #220320
In reply to: No Results Found With Filter
AnonymousInactiveThanks! That worked well.
Just out of curiosity, my code works but I have such a rudimentary understanding of PHP I only want the fields “image” and “business_description” to display if it exists. This is what I got. How can I add that in or is there some post I can look at to figure it out. `<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link https://searchandfilter.com
* @copyright 2018 Search & Filter
*
* Note: these templates are not full page templates, rather
* just an encaspulation of the your results loop which should
* be inserted in to other pages by using a shortcode – think
* of it as a template part
*
* This template is an absolute base example showing you what
* you can do, for more customisation see the WordPress docs
* and using template tags –
*
* http://codex.wordpress.org/Template_Tags
*
*/if ( $query->have_posts() )
{
?>
<?php
$header_link = the_field(‘business_website_address_url’);
?><?php
while ($query->have_posts())
{
$query->the_post();?>
<div>
<h2><a href=”<?php the_field(‘business_website_address_url’); ?>”><?php the_title(); ?></a></h2>
<div class=”desc”><img src=”<?php the_field(‘image’); ?>”><p><?php the_field(‘business_description’) ?></p></div>
<p class=”details”> Website: <a href=”<?php the_field(‘business_website_address_url’); ?>” target=”_blank”><?php the_field(‘business_website_address_url’) ?></a></p>
<p class=”details”> Phone: <a href=”tel:<?php the_field(‘phone’); ?>”><?php the_field(‘phone’) ?></a></p>
<p class=”details”> Booth: <?php the_field(‘booth_number’) ?></p></div>
<hr />
<?php
}
?>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘More Exhibitors’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Previous Exhibitors’ ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists(‘wp_pagenavi’))
{
echo “<br />”;
wp_pagenavi( array( ‘query’ => $query ) );
}
?>
</div>
<?php
}
else
{
echo “No Results Found”;
}
?>`August 30, 2019 at 2:07 pm #220031In reply to: Display No Result If No Search String Entered
TrevorParticipantFrom your original code I would have had this:
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: these templates are not full page templates, rather * just an encaspulation of the your results loop which should * be inserted in to other pages by using a shortcode - think * of it as a template part * * This template is an absolute base example showing you what * you can do, for more customisation see the WordPress docs * and using template tags - * * http://codex.wordpress.org/Template_Tags * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(233)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { if ( $query->have_posts() ) { ?> <?php while ($query->have_posts()) { $query->the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"> <h2><?php the_title(); ?></h2> <?php if( get_field('summary_portfolio_description') ): ?> <p><?php the_field('summary_portfolio_description'); ?></p> <?php endif; ?> <?php the_excerpt(); ?> </a> </article> <?php } } else { echo "<span id='no-results'>No results found, please try altering your search criteria.</span>"; } } ?>August 29, 2019 at 5:26 pm #219986In reply to: Display No Result If No Search String Entered
AnonymousInactiveHi Trevor,
Thanks for the code, just to clarify my code before was working okay it was just when I added the additional lines for the feature that checks if the user has entered anything where it broke. This was my original code:
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: these templates are not full page templates, rather * just an encaspulation of the your results loop which should * be inserted in to other pages by using a shortcode - think * of it as a template part * * This template is an absolute base example showing you what * you can do, for more customisation see the WordPress docs * and using template tags - * * http://codex.wordpress.org/Template_Tags * */ if ( $query->have_posts() ) { ?> <?php while ($query->have_posts()) { $query->the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"> <h2><?php the_title(); ?></h2> <?php if( get_field('summary_portfolio_description') ): ?> <p><?php the_field('summary_portfolio_description'); ?></p> <?php endif; ?> <?php the_excerpt(); ?> </a> </article> <?php } } else { echo "<span id='no-results'>No results found, please try altering your search criteria.</span>"; } ?>I try adding your code above and it shows results but it also shows results when nothing has been entered and the user first lands on the page?
Does that make sense?
Thanks,
James
August 29, 2019 at 3:39 pm #219959Topic: Search and Filter Throwing a Fatal PHP Error
in forum Search & Filter Pro
AnonymousInactiveHi there,
Within the past few days, the search and filter plugin (v. 2.4.6) has stopped working on my site on the following page: https://teaepicure.com/top-teas/Here’s the error it throws:
PHP Fatal error: Uncaught Error: Call to undefined function the_field() in /www/wp-content/themes/Tea Epicure/search-filter/results.php:67″
Any idea why this is happening? The content on the site has not changed, nor has my search or filter. Just some plugin updates, so it seems a plugin update has caused this error?
Tony
June 3, 2019 at 10:45 am #213056In reply to: Custom Fields doesn't show up (results.php)
TrevorParticipantGreat to see this, but it would be better to test if the field has a value before echoing it, maybe like this:
<?php if( get_field('bfo') ):?> <p>BFO: <?php the_field('bfo'); ?></p> <?php endif; ?>I will close this thread for now.
April 17, 2019 at 3:40 pm #208613In reply to: displaying acf values on results.php
TrevorParticipantFirst, make sure that you followed the guide for customization here:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
Then, editing the code, it would looks something like this:
<?php if( get_field('flow_rate') ):?> <p>Flow Rate: <?php the_field('flow_rate'); ?></p> <?php endif; ?>Should be all you need.
April 17, 2019 at 3:28 pm #208610Topic: displaying acf values on results.php
in forum Search & Filter Pro
AnonymousInactiveHello
I’m a beginner.
I want to ask how I can show the acf custom field value on the results.php page.now i try <?php the_field(‘flow_rate’); ?>
but can’t work. :'(can you help me?
thank you so much.March 23, 2019 at 6:57 am #206079In reply to: Shortcodes in excerpt
TrevorParticipantDid you try wrapping that code in a do_shortcode function?
<?php if( get_field('my_custom_field') ):?> <p>My Custom Field Value: <?php do_shortcode(the_field('my_custom_field')); ?></p> <?php endif; ?>I am not sure if that would work. Otherwise you may need to use PHP string functions to fetch the string as before, then split it up into before the button shortcode, the shortcode and the what comes after, and then handle them, with the shortcode being output in a do_shortcode function.
March 22, 2019 at 9:52 am #205982In reply to: Shortcodes in excerpt
AnonymousInactiveIs the page loading using Ajax? If so, that will be the issue, as the player you are using needs reinitialising after an Ajax load. What player are you using?
I am using Ajax to load the page. I am using standard WP audio shortcode.
I turned Ajax off and all is good now. Thanks!<?php if( get_field(‘my_custom_field’) ):?>
<p>My Custom Field Value: <?php the_field(‘my_custom_field’); ?></p>
<?php endif; ?>thanks, I will try
PS Very good support speed!
March 22, 2019 at 9:44 am #205978In reply to: Shortcodes in excerpt
TrevorParticipantIs the page loading using Ajax? If so, that will be the issue, as the player you are using needs reinitialising after an Ajax load. What player are you using?
As to ACF fields. Let us assume it is a single value field use key is
my_custom_fieldand the prefix required isMy Custom Field Value, then the PHP is this:<?php if( get_field('my_custom_field') ):?> <p>My Custom Field Value: <?php the_field('cial_secteur'); ?></p> <?php endif; ?> -
AuthorSearch Results
Search Results for 'the_field'
-
Search Results
-
Hi there,
Within the past few days, the search and filter plugin (v. 2.4.6) has stopped working on my site on the following page: https://teaepicure.com/top-teas/Here’s the error it throws:
PHP Fatal error: Uncaught Error: Call to undefined function the_field() in /www/wp-content/themes/Tea Epicure/search-filter/results.php:67″
Any idea why this is happening? The content on the site has not changed, nor has my search or filter. Just some plugin updates, so it seems a plugin update has caused this error?
Tony
Hello
I’m a beginner.
I want to ask how I can show the acf custom field value on the results.php page.now i try <?php the_field(‘flow_rate’); ?>
but can’t work. :'(can you help me?
thank you so much.