Posts being viewed (5 posts)

  1. D J
    Posted 3 years ago #

    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

          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

  2. jasonmartin55
    Posted 3 years ago #

    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.

  3. D J
    Posted 3 years ago #

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

  4. bcworkz
    Posted 3 years ago #

    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.

  5. D J
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic