Need to know custom code to display random and most viewed posts in wordpress posts and pages

A standard WordPress install doesn’t keep track of visits to pages/posts. So without a plugin there’s no way to know which posts/pages are visited most often. As to finding random posts that’s as simple as: $args = array( ‘post_type’ => array( ‘post’, ‘page’, ‘my-custom-post-type’ ) ‘orderby’ => ‘rand’, ); $query = new WP_Query ($args);

WordPress stats: OWA plugin overhead in the future

I hadn’t used this specific solution, but any self-hosted analytics in general should be considered potentially huge resource hog: every async action in WordPress is effectively another WP core load, so if tracking code makes even one additional async request to back-end it effectively doubles the load; stat logging by nature cannot be cached; stat … Read more

Get total views of all posts by author

Gathering page view statistics is inherently write operation, which is inherently heavy on resources. There are no appropriate mechanisms in WP for high volume writes at low resource consumption. Your best bet is using external analytics system/service and retrieving page view data from it.

How to track clicks

Unless you have a “religious” objection to share data with google then using GA is just the simplest and best way to go. Storing stats in your DB is a good start if you want to bring your server down when there is slightly high traffic, and in any case you can get all the … Read more

Add estimated value for a post according to the number of words

Here’s an idea for a starting point, by looking how the word counting is done in the /wp-admin/js/post.js file: /** * Testing word price calculations */ add_action( ‘after_wp_tiny_mce’, function() { ?><script> ( function( $ ) { $( function() { // Init var $content = $( ‘#content’ ), $count = $( ‘#wp-word-count’ ).find( ‘.word-count’ ), total_price … Read more