Posts being viewed

I would suggest a way to implement this to be in the post template have a call that updates post meta with the current timestamp. Then you can show posts that have been viewed recently by querying meta data for all values within a certain time range ordered by that timestamp.

an action hook when a post reaches a certain number of views

Use the action from update_post_meta(): do_action( “updated_{$meta_type}_meta”, // example: updated_post_meta $meta_id, $object_id, // post ID $meta_key, // ‘view’ $_meta_value // view count ); Something like this should work (not tested): add_action( ‘update_post_meta’, ‘badge_check’, 10, 4 ); function badge_check( $meta_id, $post_id, $key, $value ) { if ( ‘views’ !== $key or 1000 > $value ) return; … Read more

count the number of views of a post excluding own views

The plugin appears to be processing the view on the wp_head hook. That means you ought to be able to do something like this: function remove_view_counter_wpse_102637() { global $post; $current_user = wp_get_current_user(); if ( is_single() && !empty($current_user) && $post->post_author == $current_user->ID ) { remove_action(‘wp_head’, ‘process_postviews’); } } add_action(‘wp_head’, ‘remove_view_counter_wpse_102637′,1); No guarantees. I don’t use that … Read more

Embed PDF into wordpress

The only reliable cross browser solution is to embed the .pdf in a iframe. add_filter(‘media_send_to_editor’, ‘my_pdf_embed’, 20, 3); function my_pdf_embed($html, $id) { $attachment = get_post($id); //fetching attachment by $id passed through $mime_type = $attachment->post_mime_type; //getting the mime-type if ($mime_type == ‘application/pdf’) { //checking mime-type $src = wp_get_attachment_url( $id ); //change the size to your liking … Read more

How get top post view for today for today post

As your question does not state, I’m assuming that this is not your main query, but rather a stand alone that tells the visitor the most viewed page of the day. Therefore I believe that an instance of the WP_Query class is what you need. /** Query the posts to find the one with the … Read more

Showing “0” pageview when there is no view

You can optimize your code a bit and localize it. I would add the results from get_post_meta() to a variable and then check the returned result an act upon that You can try something like this <div class=”mypageview”> <?php $views = get_post_meta( $post->ID, ‘pageview’, true ); if ( !$views ) _e( ‘0 post views’ ); … Read more

How to unlink all posts from tracking same amount of views

Use this in the loop: getPostViews(get_the_ID()); instead of: bac_PostViews(get_the_ID()); So your loop should be like this: <?php $catquery = new WP_Query(array( ‘meta_key’ => ‘post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘posts_per_page’ => 5, ‘cat’ => ’52’, )); ?> <ol class=”topheadlines”> <?php while($catquery->have_posts()) : $catquery->the_post(); ?> <!– display view count –> <?php if(function_exists(‘getPostViews’)) { echo getPostViews(get_the_ID()); }?> <div class=”row”> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)