• Hi
    How to migrate views with WordPress Popular Posts ?
    I copied some text from WordPress Popular Posts support forum here below:

    Love the plugin, been using it for ages now. (“WordPress Popular Posts”)

    I have a plugin that basically searches and filters my posts. It has the option to “sort” these posts using a “meta value“. It seems WPP doesn’t have a meta value as I was hoping it would have some sort of “wpp_view_number” meta value or something along those lines.

    Is it possible to create this for the plugin and assign it to all posts? Or is there actually a meta value already there that’s possibly hidden?

    Thanks!.…..

    And response from WordPress Popular Posts plugin author:

    Hi there!

    No, WPP doesn’t store any meta data in your database (althought I’ve been thinking for a while that it probably should, might come in handy in the future.)

    Fortunately, if you follow the first step from this post you’ll get what you need 🙂
    …………………

    Can this help you to suggest me your function snippet what could be
    Implemented​ to import WordPress Popular Posts views to Post Views Counter views ?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author dFactory

    (@dfactory)

    Hi,

    This plugin probably sotres the data somewhere, but in order to migrate it to Post Views Counter in a simple, one click way it would have to be stored in meta key.

    Most plugins do it this way – store the total views data in a specific meta key. PVC is capable of importing that automatically for WP Postviews plugin or other plugins via “pvc_import_meta_key” filter hook (some code snippets are available in our support forum).

    Thread Starter anti321

    (@anti321)

    Tnx..

    If meta key was ” total_ views ” how would your plugin
    Import function look like ?

    Example i know :
    function custom_pvc_import_meta_key( $meta_key ) {
    // Use your meta-key here
    $meta_key = ‘post_views_count’;
    return $meta_key;
    }
    add_filter( ‘pvc_import_meta_key’, ‘custom_pvc_import_meta_key’ );

    But where to put “total_views” ?.. how this code look like with (total_views) meta key..?

    Thnx..

    Plugin Author dFactory

    (@dfactory)

    If the meta key was “total_views” then it would look like:

    function custom_pvc_import_meta_key( $meta_key ) {
    	// Use your meta-key here
    	$meta_key = 'total_views';
    	return $meta_key;
    }
    
    add_filter( 'pvc_import_meta_key', 'custom_pvc_import_meta_key' );

    You add that to your theme functions.php and then use the Import Views in PVC.

    Thread Starter anti321

    (@anti321)

    Thanks..

    Got my post meta key made by this link

    Current custom field is ” views_total ” from WordPress popular Post

    My theme user function.php currently is is:

    function custom_pvc_import_meta_key( $meta_key ) {
    // Use your meta-key here
    $meta_key = ‘views_total’;
    return $meta_key;
    }

    add_filter( ‘pvc_import_meta_key’, ‘custom_pvc_import_meta_key’ );

    /* Storing views of different time periods as meta keys */
    add_action( ‘wpp_post_update_views’, ‘custom_wpp_update_postviews’ );

    function custom_wpp_update_postviews($postid) {
    // Accuracy:
    // 10 = 1 in 10 visits will update view count. (Recommended for high traffic sites.)
    // 30 = 30% of visits. (Medium traffic websites)
    // 100 = Every visit. Creates many db write operations every request.

    $accuracy = 100;

    if ( function_exists(‘wpp_get_views’) && (mt_rand(0,100) < $accuracy) ) {
    // Remove or comment out lines that you won’t be using!!
    update_post_meta( $postid, ‘views_total’, wpp_get_views( $postid ) );

    }
    }

    ……
    If anyone else has WordPress popular post and wants migrate..
    Only down side is like i understood is.. have to manually view post to generate
    custom fields..

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Migrate views count ( WordPress Popular Posts )’ is closed to new replies.