Tagged: Nothing Found, search, search results
-
AuthorPosts
-
March 3, 2019 at 5:04 am #1073812
Hello Sirs,
I use search only for products and I use the grid layout in the search results.
@Ismael supported me giving the following code for search.php:I replaced: get_template_part( ‘includes/loop’, ‘search’ );
With:
global $posts;
$post_ids = array();
foreach($posts as $post) $post_ids[] = $post->ID;if(!empty($post_ids))
{
$atts = array(
‘type’ => ‘grid’,
‘items’ => get_option(‘posts_per_page’),
‘columns’ => 3,
‘class’ => ‘avia-builder-el-no-sibling’,
‘paginate’ => ‘yes’,
‘use_main_query_pagination’ => ‘yes’,
‘custom_query’ => array( ‘post__in’=>$post_ids, ‘post_type’=>get_post_types() )
);$blog = new avia_product_slider($atts);
$blog->query_entries();
echo “<div class=’entry-content-wrapper’>”.$blog->html().”</div>”;
}My issue now is when the search doesn’t find any product, the term: “Nothing Found” is missing from the search results.
Best regards,
Nick- This topic was modified 5 years, 8 months ago by nickgin.
March 6, 2019 at 8:58 pm #1075623Hey nickgin,
You need to check if you got anything back and show appropriate message.
If you need further assistance please let us know.
Best regards,
VictoriaMarch 6, 2019 at 9:53 pm #1075653Hi Victoria,
Thank you for your quick reply.
Could you help me on that please?
Best regards,
NickMarch 11, 2019 at 3:35 am #1077184Hi,
Thanks for the update.
Can you provide the whole content of the file or modification? Please post it on pastebin. We’ll check this again afterwards.
Best regards,
IsmaelMarch 11, 2019 at 4:16 am #1077194Hi Ismael,
Thank you for your excellent support! I really appreciate it!
I am providing you the whole content of search.php:
<?php
if ( !defined(‘ABSPATH’) ){ die(); }global $avia_config;
/*
* get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
*/
get_header();// allows to customize the layout
do_action( ‘ava_search_after_get_header’ );$results = avia_which_archive();
echo avia_title(array(‘title’ => $results ));do_action( ‘ava_after_main_title’ );
?><div class=’container_wrap container_wrap_first main_color <?php avia_layout_class( ‘main’ ); ?>’>
<div class=’container’>
<main class=’content template-search <?php avia_layout_class( ‘content’ ); ?> units’ <?php avia_markup_helper(array(‘context’ => ‘content’));?>>
<div class=’page-heading-container clearfix’>
<section class=”search_form_field”>
<?php
echo “<h4>”.__(‘New Search’,’avia_framework’).”</h4>”;
echo “<p>”.__(‘If you are not happy with the results below please do another search’,’avia_framework’).”</p>”;get_search_form();
echo “<span class=’author-extra-border’></span>”;
?>
</section>
</div><?php
if(!empty($_GET[‘s’]) || have_posts())
{
echo “<h4 class=’extra-mini-title widgettitle’>{$results}</h4>”;/* Run the loop to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-search.php and that will be used instead.
*/
$more = 0;
global $posts;
$post_ids = array();
foreach($posts as $post) $post_ids[] = $post->ID;if(!empty($post_ids))
{
$atts = array(
‘type’ => ‘grid’,
‘items’ => get_option(‘posts_per_page’),
‘columns’ => 4,
‘class’ => ‘avia-builder-el-no-sibling’,
‘paginate’ => ‘yes’,
‘use_main_query_pagination’ => ‘yes’,
‘custom_query’ => array( ‘post__in’=>$post_ids, ‘post_type’=>get_post_types() )
);$blog = new avia_product_slider($atts);
$blog->query_entries();
echo “<div class=’entry-content-wrapper’>”.$blog->html().”</div>”;
}}
?>
<!–end content–>
</main><?php
//get the sidebar
$avia_config[‘currently_viewing’] = ‘page’;get_sidebar();
?>
</div><!–end container–>
</div><!– close default .container_wrap element –>
<?php get_footer(); ?>
I am looking forward to your news.
Best regards,
NickMarch 11, 2019 at 3:18 pm #1077364Hi,
Thanks for the update.
Try to put this code:
if(empty($post_ids)) { echo "<div class='entry-content-wrapper'>".__('No products found.', 'avia_framework')."</div>"; }
.. right after this line:
echo “<div class=’entry-content-wrapper’>”.$blog->html().”</div>”;
Best regards,
IsmaelMarch 11, 2019 at 4:52 pm #1077416Hi Ismael,
Thank you for your quick reply.
Unfortunately, nothing happed.
I am providing you additional information:
Page URL: https://zoomit.gr/wordpress_2/?s=fdgfdgdgdf
screenshot: https://prnt.sc/mwd5tnWhole search.php with your modification:
<?php
if ( !defined(‘ABSPATH’) ){ die(); }global $avia_config;
/*
* get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
*/
get_header();// allows to customize the layout
do_action( ‘ava_search_after_get_header’ );$results = avia_which_archive();
echo avia_title(array(‘title’ => $results ));do_action( ‘ava_after_main_title’ );
?><div class=’container_wrap container_wrap_first main_color <?php avia_layout_class( ‘main’ ); ?>’>
<div class=’container’>
<main class=’content template-search <?php avia_layout_class( ‘content’ ); ?> units’ <?php avia_markup_helper(array(‘context’ => ‘content’));?>>
<div class=’page-heading-container clearfix’>
<section class=”search_form_field”>
<?php
echo “<h4>”.__(‘New Search’,’avia_framework’).”</h4>”;
echo “<p>”.__(‘If you are not happy with the results below please do another search’,’avia_framework’).”</p>”;get_search_form();
echo “<span class=’author-extra-border’></span>”;
?>
</section>
</div><?php
if(!empty($_GET[‘s’]) || have_posts())
{
echo “<h4 class=’extra-mini-title widgettitle’>{$results}</h4>”;/* Run the loop to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-search.php and that will be used instead.
*/
$more = 0;
global $posts;
$post_ids = array();
foreach($posts as $post) $post_ids[] = $post->ID;if(!empty($post_ids))
{
$atts = array(
‘type’ => ‘grid’,
‘items’ => get_option(‘posts_per_page’),
‘columns’ => 4,
‘class’ => ‘avia-builder-el-no-sibling’,
‘paginate’ => ‘yes’,
‘use_main_query_pagination’ => ‘yes’,
‘custom_query’ => array( ‘post__in’=>$post_ids, ‘post_type’=>get_post_types() )
);$blog = new avia_product_slider($atts);
$blog->query_entries();
echo “<div class=’entry-content-wrapper’>”.$blog->html().”</div>”;
if(empty($post_ids)) {
echo “<div class=’entry-content-wrapper’>”.__(‘No products found.’, ‘avia_framework’).”</div>”;
}
}}
?>
<!–end content–>
</main><?php
//get the sidebar
$avia_config[‘currently_viewing’] = ‘page’;get_sidebar();
?>
</div><!–end container–>
</div><!– close default .container_wrap element –>
<?php get_footer(); ?>
I am looking forward to your news.
Best regards,
NickMarch 14, 2019 at 12:42 am #1078459Hi,
Can you paste the code to pastebin please, so it is easier for us to read?
Best regards,
BasilisMarch 14, 2019 at 2:16 am #1078493Hi Basilis,
Thank you for your support!
Yes, of course.
https://pastebin.com/eDKj8bHhI am looking forward to your news.
Best regards,
NickMarch 18, 2019 at 10:55 am #1079808Hi,
Thanks for the update.
We modified the code a bit. Please try it again.
// https://pastebin.com/rX2rW7Dq
Best regards,
IsmaelMarch 18, 2019 at 5:43 pm #1079987Hi Ismael,
One more time you are great! The best moderator!!!Thank you so much!
You can close this ticket.Best regards,
NickMarch 20, 2019 at 4:37 pm #1080908 -
AuthorPosts
- The topic ‘Nothing found search result issue’ is closed to new replies.