Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter dreamsoft

    (@dreamsoft)

    and also adding a time limit would be great. to show most favorited posts in the last week or month

    create a page template

    <ol>
    <?php if (function_exists('wpfp_widget_view')): ?>
    <?php wpfp_widget_view('15'); ?>
    <?php endif; ?>
    </ol>

    Options pass did not work for me, but it displays what is listed in the widget settings should be applied in the admin

    Thread Starter dreamsoft

    (@dreamsoft)

    seems to work! thanks
    tho time limit can’t be added (the widget only has the option to limit to a certain number)

    and I get this error Warning: extract() expects parameter 1 to be array, string given in /home/myuser/public_html/wp-content/plugins/wp-favorite-posts/wpfp-widgets.php on line 4

    any clue why is this appearing?
    on line 4 I see extract($args);

    Thread Starter dreamsoft

    (@dreamsoft)

    changed it to <?php wpfp_widget_view(array('15')); ?> and the error is gone.
    I am still interested to limit by number of days ?? that would be great

    You know WP-PostViews plugin?

    In it, the file wp-postviews.php
    You can create a new function (approximately 266 line)

    ### Function: Display month viewed Page/Post
    if(!function_exists('get_month_viewed')) {
    	function get_month_viewed($mode = '', $limit = 50, $chars = 0, $display = true) {
    		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;
    		}
    	}
    }

    meta_key = ‘views’ replaced by ‘wpfp_favorites’

    All this is not right, but I have to retrieve the past month most viewed work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display most favorited posts in a page’ is closed to new replies.