• D J

    (@wwwpornolatinonet)


    I am looking for a way to list posts being viewed but I can’t find anything online.

    Is it even possible? I’ve seen some websites that have these loops, “What other readers are currently reading”.

    I’m using the following loop to list random set of videos

    <?php
          if ( is_home() ){
          $cat = get_query_var( 'cat' );
          query_posts(array('orderby' => 'rand', 'showposts' => 10, 'cat'=>$cat));
          }
          while (have_posts()) : the_post();
      ?>

    How can I show posts being viewed? anyone

Viewing 4 replies - 1 through 4 (of 4 total)
  • you mean list them as top posts being viewed? There is a plugin for that if you search the plugins.

    If you mean just to show views on each post, not sure.

    Thread Starter D J

    (@wwwpornolatinonet)

    Hi, I need a loop in order to display the posts being viewed currently or read sitewide

    Moderator bcworkz

    (@bcworkz)

    Perhaps you can store post titles as transients as each post template is served. Then where ever you want to display this info, just retrieve the transient values. The tricky part will be how to handle multiple currently read posts without overwriting the previous entry. Approaches involving arrays or multiple transient “slots” come to mind.

    Thread Starter D J

    (@wwwpornolatinonet)

    That sounds complicated lol, I guess the other option would be to use a meta key and store timestamp as a value and create a loop within a time range of say 1 minute.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Posts being viewed’ is closed to new replies.