| Revision 910,
1.3 KB
checked in by MtDewVirus, 7 years ago
(diff) |
|
Change variable and update readme
|
| Line | |
|---|
| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Plugin Name: Recent Posts
|
|---|
| 4 | Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/
|
|---|
| 5 | Description: Returns a list of the most recent posts.
|
|---|
| 6 | Version: 1.07
|
|---|
| 7 | Author: Nick Momrik
|
|---|
| 8 | Author URI: http://mtdewvirus.com/
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | function mdv_recent_posts($no_posts = 5, $before = '<li>', $after = '</li>', $hide_pass_post = true, $skip_posts = 0, $show_excerpts = false) {
|
|---|
| 12 | global $wpdb;
|
|---|
| 13 | $time_difference = get_settings('gmt_offset');
|
|---|
| 14 | $now = gmdate("Y-m-d H:i:s",time());
|
|---|
| 15 | $request = "SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' ";
|
|---|
| 16 | if($hide_pass_post) $request .= "AND post_password ='' ";
|
|---|
| 17 | $request .= "AND post_date_gmt < '$now' ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
|
|---|
| 18 | $posts = $wpdb->get_results($request);
|
|---|
| 19 | $output = '';
|
|---|
| 20 | if($posts) {
|
|---|
| 21 | foreach ($posts as $post) {
|
|---|
| 22 | $post_title = stripslashes($post->post_title);
|
|---|
| 23 | $permalink = get_permalink($post->ID);
|
|---|
| 24 | $output .= $before . '<a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . htmlspecialchars($post_title, ENT_COMPAT) . '">' . htmlspecialchars($post_title) . '</a>';
|
|---|
| 25 | if($show_excerpts) {
|
|---|
| 26 | $post_excerpt = stripslashes($post->post_excerpt);
|
|---|
| 27 | $output.= '<br />' . $post_excerpt;
|
|---|
| 28 | }
|
|---|
| 29 | $output .= $after;
|
|---|
| 30 | }
|
|---|
| 31 | } else {
|
|---|
| 32 | $output .= $before . "None found" . $after;
|
|---|
| 33 | }
|
|---|
| 34 | echo $output;
|
|---|
| 35 | }
|
|---|
| 36 | ?> |
|---|
Note: See
TracBrowser
for help on using the repository browser.