Title: After update not work my script in function.php
Last modified: March 31, 2017

---

# After update not work my script in function.php

 *  Resolved [SimcaCZE](https://wordpress.org/support/users/simcacze/)
 * (@simcacze)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/after-update-not-work-my-script-in-function-php/)
 * Hi, I try update your plugin to 1.75. After update not work some script in function.
   php
    Example:
 *     ```
        if (!function_exists('get_most_viewed2')) {
   
               function get_most_viewed2($mode = '', $limit = 10, $chars = 0, $display = true) {
                   echo "<ul>";
                   global $wpdb, $post;
                   $views_options = get_option('views_options');
                   $where = '';
                   $temp = '';
                   $output = '';
                   if (!empty($mode) && $mode != 'both') {
                       $where = "post_type = '$mode'";
                   } else {
                       $where = '1=1';
                   }
                   $start_date = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
                   $date_limit = "post_date BETWEEN '" . date("Y-m-d", $start_date) . "' AND '" . current_time('mysql') . "'";
   
                   $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE $date_limit AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER  BY views DESC LIMIT $limit");
                   if ($most_viewed) {
                       foreach ($most_viewed as $post) {
                           $post_views = intval($post->views);
                           $post_title = get_the_title();
                           if ($chars > 0) {
                               $post_title = snippet_text($post_title, $chars);
                           }
                           $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
                           $post_content = get_the_content();
                           $temp = stripslashes($views_options['most_viewed_template']);
                           $temp = str_replace("%VIEW_COUNT%", number_format_i18n($post_views), $temp);
                           $temp = str_replace("%POST_TITLE%", $post_title, $temp);
                           $temp = str_replace("%POST_EXCERPT%", $post_excerpt, $temp);
                           $temp = str_replace("%POST_CONTENT%", $post_content, $temp);
                           $temp = str_replace("%POST_URL%", get_permalink(), $temp);
                           $output .= $temp;
                       }
                   } else {
                       $output = '<li>' . __('N/A', 'wp-postviews') . '</li>' . "\n";
                   }
                   if ($display) {
                       echo $output;
                   } else {
                       return $output;
                   }
                   echo "</ul>";
               }
   
           }
       ```
   
 * I must get at hosting old version 1.74.
 * Thanks for correct this errors. It is not one php script. They are for my php
   script.
    Jirka Borovy – [Kritiky.cz](http://www.kritiky.cz/clanky/2009/kmotr/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/after-update-not-work-my-script-in-function-php/#post-8978029)
 * The plugin has been revamped to use WP_Query to query for post. So if you have
   custom dependencies on it, it might break.
 * If you need download 1.74, [https://downloads.wordpress.org/plugin/wp-postviews.1.74.zip](https://downloads.wordpress.org/plugin/wp-postviews.1.74.zip)

Viewing 1 replies (of 1 total)

The topic ‘After update not work my script in function.php’ is closed to new replies.

 * ![](https://ps.w.org/wp-postviews/assets/icon.svg?rev=978002)
 * [WP-PostViews](https://wordpress.org/plugins/wp-postviews/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-postviews/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-postviews/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-postviews/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-postviews/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-postviews/reviews/)

## Tags

 * [Thank](https://wordpress.org/support/topic-tag/thank/)

 * 1 reply
 * 2 participants
 * Last reply from: [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/after-update-not-work-my-script-in-function-php/#post-8978029)
 * Status: resolved