define orderby URL with meta_key=post_views_count
define orderby URL with meta_key=post_views_count
define orderby URL with meta_key=post_views_count
I’m not sure why are you hooking into the_content filter. You could use a more appropriate action hook, such as wp_head: <?php add_action ( ‘wp_head’, ‘update_user_count’ ); // note function update_user_count() { global $post; // Make sure you only get the int part $counter = ( int ) get_post_meta( $post->ID, ‘views’, true ); // increment … Read more
Ah! jQuery to the rescue! function custom_admin_js() { global $get_all_statuses; ?> <script type=”text/javascript”> jQuery(document).ready(function($) { //Bring my $get_all_statuses array and encode it for jquery var myObjects = <?php echo json_encode($get_all_statuses);?>; //Run a each loop : jquery equivalent to php’s foreach $.each(myObjects, function (index, value) { //console.log(index); //Status Label //console.log(index); //Status-name //count the WP list rows … Read more
As you are doing update_post_meta( $post_id, $key, $count ); for which $key is ‘post_views_count’, you can’t. You are updating the meta key as is. You could however change how you are saving the meta key. You could add a prefix to the meta key you’re using to differentiate the day, week, and month. example for … Read more
Post views log/count is not available natively. It is resource-intensive (database writes are much more expensive than reads) and won’t work (if done in pure PHP) with most caching plugins. There is number of plugins/services that offers Analytics via JS- or image-based tracking. Your best bet is to let such service handle analytics and pull … Read more
As it turns out, with the introduction of the WP_List_Table class, view filter are now hookable and specifically you can filter out that detached link like so.. add_filter( ‘views_upload’, ‘upload_views_filterable’ ); function upload_views_filterable( $views ) { unset( $views[‘detached’]); return $views; } Bye bye detached link!… 🙂
Undo any changes you’ve have made to the file, then add this at the top: if ( jQuery.cookie( “gridcookie” ) != “grid” ) { jQuery.cookie( “gridcookie”, “list”, { path: “https://wordpress.stackexchange.com/” } ); } Update: Sounds like a FOUC. Let’s take a different approach – remove the code you added above & try adding the following … Read more
You can try: $the_query = new WP_Query( array( ‘posts_per_page’ => ‘5’, ‘v_sortby’ => ‘views’, ‘post_type’ => array( ‘post’, ‘music’, ‘videos’, ‘albums’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘content’, ‘field’ => ‘slug’, ‘terms’ => array( ‘indy’ ), ‘operator’ => ‘NOT IN’ ) ) )); to exclude the indy term in the content taxonomy.
There’s no way to identify when each of the page view’s recorded happened. It’s only logging the page view, not when it happened. To work around this you could keep a post_meta entry for each view, but this could create a lot of entries on popular sites. Alternatively you could keep daily counts & delete … Read more
The issue was that the $query->set in the filter function was updating the main query used to count the number of posts. Likely due to the order in which they were called. I tried to flush and run a new wp_query but what ultimately worked best was the function below that uses a custom query. … Read more