WordPress.org

Ready to get started?Download WordPress

Forums

Business Directory Plugin
[resolved] Featured Listings not working (10 posts)

  1. lujeffcoat
    Member
    Posted 1 year ago #

    I just updated the plugin and when I did, my featured listings are no longer displaying at the top of the page, they are just listed in alphabetical order.

    Also, I noticed that when I click Manage Featured in the backend, my featured listings to not show up there. I don't think this ever worked, this is not something that changed with the upgrade. But i have customers paying to have their listings at the top of the page, so it is imperative that I get those back at the top of the page.

    http://wordpress.org/extend/plugins/business-directory-plugin/

  2. lujeffcoat
    Member
    Posted 1 year ago #

    Sorry, I forgot to add the URL where you can see it's not working - http://www.visitncwinecountry.com/directory/?category=wineries-and-vineyards

  3. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    Hi lujeffcoat,

    You say that you don't have featured listings or you're not sure if they're really featured or not...I'm confused.

    Can you show me a screenshot of the admin panel (Directory->Directory) with the "featured" listings visible? Are they showing "Featured" in their status? If not, then BD will not treat them as a special listing.

    If they are showing like that, then can you provide us access to your site (admin), via the contact form: http://businessdirectoryplugin.com/contact/. I'll have my developer take a look.

  4. lujeffcoat
    Member
    Posted 1 year ago #

    Sorry for the confusion. I do have featured listings. I sent you admin credentials so that you can login and see what I am talking about. The featured winery listings used to show at the top of http://www.visitncwinecountry.com/directory/?category=wineries-and-vineyards. Now, you can scroll down and see Banner Elk has the colored background like a featured listing, but it's not displaying at the top of the page. I have a few others that are just listed in alphabetical. All featured wineries should be at the top, then the rest of the listings below that in alphabetical order. Let me know if there is anything else I can send you. Thanks so much for looking into this.

  5. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    Should be fixed now in the email I sent. This was a plugin conflict issue.

  6. lujeffcoat
    Member
    Posted 1 year ago #

    THank you so much for helping out - you rock :)

  7. DanVilla
    Member
    Posted 9 months ago #

    Hellow, i was wondering if someone could help me with my featured listing widget. You see in this page : http://www.psicologiavenezuela.net im using a featured listing in the column called "Profesionales Dstacados". Now, i managed to custom the code so this widget could display the data in a random way but, now i need to change it back so it displays in a regular way by only selecting the first 5 records from the database and i dont know how to do so..

    this is the code of my featured listing class:

    class WPBDP_FeaturedListingsWidget extends WP_Widget {
    
        public function __construct() {
            parent::__construct(false, _x('Business Directory - Featured Listings', 'widgets', 'WPBDM'),
                                array('description' => _x('Displays a list of the featured/sticky listings in the directory.', 'widgets', 'WPBDM')));
        }
    
        public function form($instance) {
            echo sprintf('<p><label for="%s">%s</label> <input class="widefat" id="%s" name="%s" type="text" value="%s" /></p>',
                         $this->get_field_id('title'),
                         _x('Title:', 'widgets', 'WPBDM'),
                         $this->get_field_id('title'),
                         $this->get_field_name('title'),
                         isset($instance['title']) ? esc_attr($instance['title']) : _x('Featured Listings', 'widgets', 'WPBDM')
                        );
            echo sprintf('<p><label for="%s">%s</label> <input class="widefat" id="%s" name="%s" type="text" value="%s" /></p>',
                         $this->get_field_id('number_of_listings'),
                         _x('Number of listings to display:', 'widgets', 'WPBDM'),
                         $this->get_field_id('number_of_listings'),
                         $this->get_field_name('number_of_listings'),
                         isset($instance['number_of_listings']) ? intval($instance['number_of_listings']) : 10
                        );
        }
    
        public function update($new_instance, $old_instance) {
            $new_instance['title'] = strip_tags($new_instance['title']);
            $new_instance['number_of_listings'] = max(intval($new_instance['number_of_listings']), 0);
            return $new_instance;
        }
    
        public function random_posts($n) {
            global $wpdb;
    
            $n = max(intval($n), 0);
    
            $query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s ORDER BY RAND() LIMIT {$n}",
                                    wpbdp_post_type(), 'publish');
            return $wpdb->get_col($query);
        }
    
     public function widget($args, $instance) {
            extract($args);
            $title = apply_filters( 'widget_title', $instance['title'] );
    
    	$post_ids = $this->random_posts($instance['number_of_listings']);
    
            if (!$post_ids) return;
    
            $posts = get_posts(array(
                'post_type' => wpbdp_post_type(),
                'post_status' => 'publish',
                'numberposts' => $instance['number_of_listings'],
                'orderby' => 'date',
                'meta_query' => array(
                    array('key' => '_wpbdp[sticky]', 'value' => 'sticky')
                ),
    			'post__in' => $post_ids
            ));
    
            if ($posts) {
                echo $before_widget;
                if ( ! empty( $title ) ) echo $before_title . $title . $after_title;
    
                echo '<ul>';
                foreach ($posts as $post) {
                    echo '<li>';
    				echo get_the_post_thumbnail($post->ID,array(32,32));
                    echo sprintf('<a id="featured-pro" href="%s">%s</a>', get_permalink($post->ID), get_the_title($post->ID));
    				echo '<br />';
    				echo '<me>';
    				echo get_post($post->ID)->post_excerpt;
    				echo '<br />';
    				echo sprintf('Dirigido a: %s', wpbdp_get_listing_field_value($post->ID,12));
    				echo '<br />';
    				echo sprintf('Tipo de abordaje: %s', wpbdp_get_listing_field_value($post->ID,13));
    				echo '</me>';
                    echo '</li>';
                }
    
                echo '</ul>';
                echo $after_widget;
            }
        }    
    
    }

    Im having a very bad time understanding wordpress templates and functions.. im sure its a simple thing but im really confused on how to do this.

  8. businessdirectoryplugin
    Member
    Plugin Author

    Posted 9 months ago #

    In the SELECT statement above, it is already limiting by %n records, where n is the setting of the widget.

    Here:

    $query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s ORDER BY RAND() LIMIT {$n}",
                                    wpbdp_post_type(), 'publish');

    How many records are you getting? The setting of the widget should control it now.

  9. DanVilla
    Member
    Posted 9 months ago #

    Well is random, sometimes i get 5 or 3 records, in any case i really dont know where i can change this setting. I have been trying to find the widget code but again im lost. One question thou, if i eliminate the ORDER BY RAND() this will allow the widget to only post the records by the order they have in the database right?

  10. businessdirectoryplugin
    Member
    Plugin Author

    Posted 9 months ago #

    That's correct. The ORDER BY RAND() is how it gets you the random ordering.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic