Blog

  • WordPress recently updated pages or posts

    This WordPress plugin creates a list of links to the most recently updated pages and posts on any WP website. The following image is a screen shot of the widget output. I am running this widget on this website, so forget the screen shot. Look at the sidebar on this page and you will find the widget itself.

    recently-updated-pages-and-posts

    Install this plugin

    1. Download recently-updated-pages-and-posts.zip
    2. Decompress the file contents
    3. Upload the recently-updated-pages-and-posts folder to a WordPress plugins directory (/wp-content/plugins)
    4. Activate the plugin from the Administration Dashboard
    5. Open the Widgets page under the Appearance section
    6. Drag the Recently updated widget to the active sidebar
    7. Configure the widget options to suit your needs and click Save

    Sample HTML output

    View sample-html-output.txt

    Styling the output with CSS

    /* reference the list by id */
    #recently-updated-widget-list{ list-style: disc; }

    /* apply style to all of the list items */
    .recently-updated-widget-item{ margin-left: 25px; }

    /* make the first list item font size larger */
    #ruwi-0{ font-size: 125%; }

    WordPress.org plugin page

    Visit this plugin’s page in the official WordPress Plugin Directory.

    Here is some code I hacked together to display a list of recently updated pages and posts on a WordPress site:


    <?php
    $today = current_time('mysql', 1);
    $howMany = 5;
    if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")):
    ?>
    <h2><?php _e("Recent Updates"); ?></h2>
    <ul>
    <?php
    foreach ($recentposts as $post) {
    if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);
    echo "<li><a href='".get_permalink($post->ID)."'>";
    the_title();
    echo '</a></li>';
    }
    ?>
    </ul>
    <?php endif; ?>

    The variable $howMany holds the number of items to display in the list. I used some code I found in a WordPress theme I am using on some website, and modified it to help someone in need of this specific solution.

    Update 02/22/2010:

    Including post excerpts

    A commenter below asks, “Is it possible to combine the_excerpt(); with the code you provided?” The function you are naming is only useful inside “the loop,” but yes, including excerpts is easy. Try this:


    <?php
    $today = current_time('mysql', 1);
    $howMany = 18;
    if ( $recentposts = $wpdb->get_results("SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")):
    ?>
    <h2><?php _e("Recent Updates"); ?></h2>
    <ul>
    <?php
    foreach ($recentposts as $post) {
    if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);
    echo "<li><a href='".get_permalink($post->ID)."'>";
    the_title();
    echo '</a><p>' . $post->post_excerpt . '</p></li>';
    }
    ?>
    </ul>
    <?php endif; ?>

  • No Blog Clients WordPress plugin

    I wrote a small WordPress plugin today to prevent these link elements from showing up in the header of my websites:


    <link rel="EditURI" type="application/rsd+xml" title="RSD" href="WPURL/xmlrpc.php?rsd" />
    <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="WPURL/wp-includes/wlwmanifest.xml" />

    The first of these link elements instruct blog clients where to find the WordPress XML-RPC interface via really simple discovery (RSD).

    The second tells Windows Live Writer where to find your WordPress administration dashboard, the location of the edit posts and manage comments scripts.

    If you are not using any blog clients to log into your WordPress and make changes to your posts or approve comments, these is no reason to be publishing these script locations.

    Download no-blog-clients.zip

    This plugin is now included in the official WP Plugins Directory.