• Resolved msmith1

    (@msmith1)


    When there’s no results there’s no indication or anything to let the viewer know that no results have been found.

    I Need to add some sort of simple text saying “No Results Found”

    Using a custom template IE the “Cars” template, is there a way to add some kind of “IF” parameter to the end of the loop is no results have been found??

    I’m surprised this hasn’t already been included within the templates.

    Thanks in advance

    • This topic was modified 5 years, 9 months ago by msmith1.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello

    Try this code:

    if($mdf_loop->found_posts<1){
    echo "No Results Found";
    }
    Thread Starter msmith1

    (@msmith1)

    Hi @pavloborysenko please understand that my knowledge of php is non existent. I don’t understand php.

    This is my current code:

    <?php if (!defined('ABSPATH')) die('No direct access allowed'); ?>
    <?php
    wp_enqueue_style('my_kitchensnew3', get_template_directory_uri() . '/mdf_templates/any/my_kitchensnew3/css/bootstrap.min.css');
    wp_enqueue_style('my_kitchensnew3-1', get_template_directory_uri() . '/mdf_templates/any/my_kitchensnew3/css/styles.css');
    global $mdf_loop;
    $zoom = 3;
    
    if (isset($_REQUEST['meta_data_filter_args']['tax_query']))
    {
        $taxes = $_REQUEST['meta_data_filter_args']['tax_query'];
        if (!empty($taxes))
        {
            foreach ($taxes as $value)
            {
                if (isset($value['taxonomy']) AND $value['taxonomy'] == 'locations')
                {
                    $zoom = 11;
                    break;
                }
            }
        }
    }
    
    echo do_shortcode('[mdf_gmap height="300" width="100" zoom="' . $zoom . '" maptype="TERRAIN" metakey="medafi_map"]');
    echo '<br />';
    MDTF_SORT_PANEL::mdtf_catalog_ordering();
    ?>
    
    <div class="row previews">
        <?php
        while ($mdf_loop->have_posts()) : $mdf_loop->the_post();
            ?>
            <div class="col-md-3">
                <div class="thumbnail">
                    <?php
                    if (has_post_thumbnail($post->ID))
                    {
                        echo '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr($post->post_title) . '">';
                        echo '<img src="' . MDTF_HELPER::get_post_featured_image($post->ID, '350x300') . '" alt="" />';
                        echo '</a>';
                    }
                    ?>
    				
    				<div class="heart11"><p style="text-align: right;">
                            <?php echo do_shortcode('[favorite_button post_id="" site_id=""]') ?>
                        </p></div>
    				
                    <div class="caption" style="max-height: 650px; text-align: left">
                        <h3><a href="<?php the_permalink() ?>" target="_blank"><?php the_title() ?></a></h3>
    
                        
                        
    
                        <br />
                        
                        <div style="clear: both;"></div>
                    </div>
                </div>
            </div>
        <?php endwhile; // end of the loop.     ?>
    </div>
    
    

    If you can show me where to implement what you have suggested I would be very very grateful.

    Thanks,

    • This reply was modified 5 years, 8 months ago by msmith1.

    Hello

    Try add the code here – https://c2n.me/3VQDr15.png

    Thread Starter msmith1

    (@msmith1)

    Thanks @pavloborysenko ….I think there may be a separate issue. Where as I initially thought that the page was displaying blank when there was no results, there was actually an error taking place. Im using the Custom shortcode to display results in an elementor themed page. So what i did was created a temporary results page without elementor to see if there would be a difference.

    Here’s what I found… With or without your code I get the following message on a page when there’s no results to show (see below)

    Fatal error: Uncaught Error: Call to undefined function do_shotrcode() in /homepages/6/d568366588/htdocs/w_bnc/wp-content/plugins/wp-meta-data-filter-and-taxonomy-filter/classes/shortcodes.php:967 Stack trace: #0 /homepages/6/d568366588/htdocs/w_bnc/wp-includes/shortcodes.php(319): MetaDataFilterShortcodes::mdf_custom(Array, '', 'mdf_custom') #1 [internal function]: do_shortcode_tag(Array) #2 /homepages/6/d568366588/htdocs/w_bnc/wp-includes/shortcodes.php(197): preg_replace_callback('/\\[(\\[?)(mdf_cu...', 'do_shortcode_ta...', '[mdf_custom tem...') #3 /homepages/6/d568366588/htdocs/w_bnc/wp-includes/class-wp-hook.php(286): do_shortcode('[mdf_custom tem...') #4 /homepages/6/d568366588/htdocs/w_bnc/wp-includes/plugin.php(203): WP_Hook->apply_filters('[mdf_custom tem...', Array) #5 /homepages/6/d568366588/htdocs/w_bnc/wp-includes/post-template.php(240): apply_filters('the_content', '[mdf_custom tem...') #6 /homepages/6/d568366588/htdocs/w_bnc/wp-content/themes/astra/template-parts/content-page.ph in /homepages/6/d568366588/htdocs/w_bnc/wp-content/plugins/wp-meta-data-filter-and-taxonomy-filter/classes/shortcodes.php on line 967

    The first thing that I noticed was the Call to undefined function do_shotrcode()
    Could this issue be because do_shotrcode is spelled incorrectly? Or do you think there may be another issue?

    I appreciate your feedback, I’m sorry If this got a little complex.

    Thanks

    Thread Starter msmith1

    (@msmith1)

    Okay so…quick update.

    I replaced the do_shotrcode with do_shortcode (Correct spelling) on line 967 and everything works now. It’s an issue within the shortcode.php file in the plugin directory that the developer should have picked up on.

    All is now resolved,

    Thanks again

    Hello

    Great!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding a “No results found” Message’ is closed to new replies.