zeitgrund blog

Plugin Last Viewed Posts (english)

Samstag, 8. Dezember 2007 um 14:59 Uhr in Last Viewed Posts, Plugins

Download the latest release (0.7.1) of the plugin Last Viewed Posts

For German description click here / für deutsche Beschreibung hier klicken

Description:
This plugin displays the posts (or pages) that have been recently viewed by the visitor (single view).
The posts are saved in in a cookie and by default the last 10 posts that have been visited are displayed.
Note that this is NOT a global listing of recently viewed posts by all users! Nothing is stored in the database.
Every vistor has his own unique listing of the single posts he has viewed.

If cookies are not accepted or no single post has been clicked, no output will be displayed.
The plugin comes with a widget and a template tag.

Screenshot

Download:
last_viewed_posts.zip (3kb)

Compatiblity:
This Plugin needs at least WordPress 2.1 but is compatible up to WordPress 2.7.

Changelog:
0.6: First public release.
0.7: Pages can now be recognized (optional). Custom Loop is not longer used. Now we make a database query to get the post title.
0.7.1: Post/Page ID values in cookie are sanitized for output.

Use:
Viewed posts are always tracked as long as the plugin is active and the visitor has enabled the cookies.

Download and unzip the plugin file. Upload last_viewed_posts.php to your /wp-content/plugins/ directory.
Go to the admin backend and activate the plugin.

To display the list, you can use the widget that comes with the plugin or use the following code and place it anywhere you want to, but outside the loop, e.g. sidebar.php :

<?php if (function_exists('zg_recently_viewed')): if (isset($_COOKIE["WP-LastViewedPosts"])) { ?>
<h2>Last viewed posts</h2>
<?php zg_recently_viewed(); ?>
<?php } endif; ?>

The single template tag is shown below, but I recommend to use the code shown above.
It prevents you from displaying a blank list if the visitor has cookies disabled or did not view any single post yet.
<?php zg_recently_viewed(); ?>

By default the cookie expires after 360 days and the number of entries that are displayed is 10.
To change these values, edit the last_viewed_posts.php between the equals sign and the semicolon:
$zg_cookie_expire = 360; // After how many days should the cookie expire? Default is 360.
$zg_number_of_posts = 10; // How many posts should be displayed in the list? Default is 10.
$zg_recognize_pages = true; // Should pages to be recognized and listed? Default is true.

This Plugin is released under the GPL.



Kommentar verfassen

Zeilen und Absätze brechen automatisch um, E-Mail Adresse wird nicht veröffentlicht (ist aber obligatorisch), HTML erlaubt: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>