WordPress.org

Ready to get started?Download WordPress

Forums

  1. TimBHowe
    Member
    Posted 1 year ago #

    Hello,
    I made a slight modification to the wp-property widget that comes in the module and I was hoping that the code could be reviewed and maybe added to the next release.

    I added the option to the wp-property widget to allow for the featured property to be shown in random order.

    in wp-property/core/class_functions.php add on line 3234
    $sql_sort_by != 'random' &&
    and in wp-property/core/class_functions.php add on line 3264 - 3279

    } elseif($sql_sort_by=='random') {
    
          $result = $wpdb->get_col("
            SELECT ID FROM {$wpdb->posts } AS p
            WHERE ID IN (" . implode(",", $matching_ids) . ")
            $additional_sql
            ORDER BY RAND() $sql_sort_order
            $limit_query");
    
          // Stores the total Properties returned
          if($total) {
            $total = count($wpdb->get_col("
              SELECT ID FROM {$wpdb->posts} AS p
              WHERE ID IN (" . implode(",", $matching_ids) . ")
              {$additional_sql}"));
          }

    in wp-property/core/class_widgets.php add on line 696
    $random_items = $instance['random_items'];
    in wp-property/core/class_widgets.php add on line 715-719

    if($random_items==1){
        $random_sort = "&sort_by=random";
      }
        $all_featured = WPP_F::get_properties("featured=true&property_type=all&pagi=0--".$amount_items.$random_sort);

    in wp-property/core/class_widgets.php add/modify on line 810
    $random_items = $instance['random_items'];
    in wp-property/core/class_widgets.php add on line 858-862

    <p>
          <label for="<?php echo $this->get_field_id('random_items'); ?>"><?php _e('Display properties in random order?', 'wpp'); ?>
            <input id="<?php echo $this->get_field_id('random_items'); ?>" name="<?php echo $this->get_field_name('random_items'); ?>" type="checkbox" value="1" <?php if(!empty($random_items)) echo ' checked="checked"'; ?> />
          </label>
        </p>

    once all this code is added the featured property page will have a check box for random sort order.

    Please let me know what you think and if it could be added to the next release. Also if any one see any better solutions of more efficient way please let me know
    Thanks
    Tim

    http://wordpress.org/extend/plugins/wp-property/

  2. Denys Kostin
    Member
    Posted 1 year ago #

    Thank you. Our devs will review your solution.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic