WordPress Plugin/Widget for Must Read Posts

Today, I was looking for a simple WordPress widget that allows me to statically display links to certain posts in the sidebar. I could have used the links widget but it wasn’t flexible enough for me. My idea was to use a certain custom field of a post or page as a trigger to display it in a widget. I searched for almost an hour but I just couldn’t find any simple, widget-capable WordPress plugins that could do this?! 

In the end, I ended up writing my own widget-capable plugin. I decided to publish it so anyone else can use it on her/his blog too. The plugin’s name is “Must Read Posts”. It shows your most recommended posts and pages in a sidebar widget or in a page. As the widget’s title is editable in the WordPress Dashboard you could change it to something like “Recommended Posts”, “Important information”, “Tips & Tricks” or whatever you like.

The plugin works using a certain custom field name called must-read. If the field exists in a page or post and has the value true, the post automatically will be shown in the widget. The next image shows the plugin in action. The Must Read Posts widget is visible in the right sidebar on this theme.

must-read-posts-in-action

Once installed, you can use it with the

<?php get_mustread('Custom Title', number of posts); ?>

 
instruction in your templates or just add it as a widget to your sidebar. If you use the widget you can also specify the maximum number of posts to be shown in the widget.

must-read-widget-config

If you use the plugin for the first time, click “Add new custom field” to add a field name must-read and insert true in the value field of the page or post you want to be shown in the new widget. Once you want to display an additional post in the widget, just select it from the custom field drop-down box and insert true in the value field.

must-read-custom-field

Installation

  1. Upload must-read-posts.php to the /wp-content/plugins/ directory.
  2. Activate “Must Read Posts” through the ‘Plugins’ menu in WordPress.
  3. What to do now depends on how up to date your theme is:

Modern theme with widget support

The plugin is also a widget. If your theme supports widgets, and you have installed the widget plugin, adding the plugin to the sidebar is easy: Go to the appearance menu and drag and drop the widget into the sidebar. Don’t forget to save your new widget structure using the save button below.

Old school theme without widget support

This will require some programming in the sidebar.php file. There are many resources on the web about how to do this.

Further Customization

The look of the list of posts and pages in the widget can be customized using the style.css cascading style sheet. Just add your own or the following style to your current theme’s style.css file:

#mustread-posts li {
   list-style-type:square;
   margin-bottom:0.4em;
}

 
The plugin is available from the WordPress plugin web site: Must Read Posts Widget.


You may also be interested to read:

41 Comments so far

  1. Marcus on December 29th, 2008

    Indeed a very simple but effective way to show important posts in a widget. Thanks for the great work! You may want to consider sharing your widget on the WP plugin website http://wordpress.org/extend/plugins/tags/plugin

  2. Jan on January 2nd, 2009

    Marcus, as of today, the plugin/widget is available from the WordPress plugin site:
    http://wordpress.org/extend/pl.....read-posts

  3. Matteo on January 14th, 2009

    Ho, I appreciate your work, but i would like to use with conditional tags in sidebar, so that visitors can see “must read posts” only when they visit a category, or archive. I paste your code in a php sidebar widget but I have an error “Call to undefined function get_must_read()”

    What’s wrong?

  4. Matteo on January 14th, 2009

    I think that Must Read Posts Plugin is incompatible with K2 sidebar module and K2 widgets.

  5. Jan on January 14th, 2009

    Matteo, you may want to try get_mustread() instead of get_must_read(), there’s an error in my documentation. The plugin/widget should be compatible to every “proper” WordPress 2.7 theme as I’m using standard WP 2.7 API calls. It may not work in pre 2.7 environments though as I’m using functions not available in versions earlier than 2.3 or 2.2.

  6. Matteo on January 15th, 2009

    Thanks for your answer, I’m trying your plugin in WP 2.5. I made the modifcation you suggest and I notify you if it works. Thank you

  7. Matteo on January 15th, 2009

    No luck, I’ve tried your plugin with WP 2.5 and K2 theme and is not possibile to view the sidebar widget in K2 sidebar management. Putting the code you give in a PHP widget cause an error.

  8. Jan on January 17th, 2009

    Matteo, the latest version (1.0.5) runs well with Exec-PHP and PHP templates in WP 2.7, I’ve just tested it. If it still doesn’t work in WP 2.5 and K2 then I don’t know why as I’m not running this environment.

  9. Matteo on January 17th, 2009

    Jan the last version of your plugin works in WordPress 2.5 with K2 sidebar manager. Thank you very much ;)

  10. Jan on January 17th, 2009

    Yay, cool!

  11. kathy on January 24th, 2009

    I cannot get changes in the “Custom field name key” box of the widget properties to stick.
    I change ‘must-read’ to my ‘2008_ts’ filed name. Hit done. it is still changed if I then click edit again, but once I ’save changes’ to the sidebar, it is reverted back to ‘must-read’ – using WP2.7, sidebar template is widgetized.

    My custom filed name change works via hard coded template calls and in posts (via exec-php) – just not within the widget …

  12. Jan on January 25th, 2009

    Kathy, I just tagged v1.0.6 that fixes this bug and uploaded it to the plugin repository. It should be available shortly. Please let me know if this fixes the problem for you.

  13. kathy on January 26th, 2009

    THANK YOU – I will let you know if it there are any probs with the update! thanks again!

  14. [...] Must Read Posts allows you to put a list of posts on your sidebar that you think your readers will like. You can set the number of posts that will be in the sidebar, and the author includes a class for styling the list. Aside from putting the widget in your sidebar, the only other thing you need to do is add a custom field in your post. Posts with the field can show up in the list, making it easy to control what will be there. It does not do much, but what it does do, works well. [...]

  15. katherine marie on February 19th, 2009

    Love this thanks a million!!!!!!!

  16. Bill Campbell on March 14th, 2009

    Hi, love what this does so far…is there a way to discover the order in which the posts are listed, and a way to change that order?

    Thanks,

    Bill Campbell

  17. Jan on March 15th, 2009

    Bill, at the moment the posts are unsorted. This means they appear as they are provided by the database. I understand that this is not an ideal way of handling the sort order. I’m planning to add some sort of sorting mechanism but I can’t say when it will be ready.

    Cheers,
    Jan

  18. [...] WP Plugin Must Read Post [trick77] erlaubt Dir ausgewählte Artikel oder statische Seiten als ganz besonders in der [...]

  19. Lee Seats on April 18th, 2009

    Thanks for the great widget plug-in. I’d too like to vote for a way to modify the order. It might be easiest to do it by accepting a numeric value for the must-read field and listing the posts based on those numbers. As a user I would enter say 10,20,30, and 40 as my initial order and then I could have the flexibility to put new posts between those without re-entering all the numbers.

  20. Jan on May 1st, 2009

    Sorting is on it’s way, I just need some time to upload it to the plugin repository.

  21. dains on May 21st, 2009

    Hi, I’m looking for an expanded version of this. I’d like to put the posts from a category onto pages instead of having to mark every post. I’d be using a customized page template so code wouldn’t be an issue.

    Have you any thoughts on how your plugin might be extended to do this?

  22. Jan on May 22nd, 2009

    Dains, I’m pretty sure you will find such a plug-in on Wordpress’ plugin site.

  23. DrFaulken on May 23rd, 2009

    This plugin was just what I needed. Thank you very much!

  24. Jeff Harding on May 27th, 2009

    Is there a finite limit on the number of posts? I changed it from 10 to 20 and it crashed my site. Worked great until then. I use it as a widget.
    Thanks.

  25. Jan on May 27th, 2009

    Jeff, I just set it to 20 and and there’s absolutely nothing odd happening. You may have entered a space or character in the box accidentally. I can’t see that something like this could happen by entering just a different value.

  26. Jeff Harding on May 31st, 2009

    Thanks for the help!

  27. Jeff Harding on May 31st, 2009

    I forgot where to find the custom field!

  28. Jeff Harding on June 1st, 2009

    OK, got it.

  29. Marie on June 3rd, 2009

    Hi Jan,

    I would like to use your code to insert whole posts on a page.
    I want it to work as if I choose must-read, the whole post should be displayed on the page.

    Do you know how I can do that?
    I tried by myself but the whole thing went totally bad.

  30. Jan on June 4th, 2009

    Marie, I’m afraid that I can’t give you any advice as I am not very skilled in PHP myself.

  31. Al Brittain on June 22nd, 2009

    Does exactly what I needed – thanks!

    It’d be nice to be able to drag the posts around in the widget to change the order, although it’s easy enough to sort the way it is now.

  32. Falcatruan on June 25th, 2009

    Hi, I just want to report you about a very simple tweak I’ve done in your plugin code (just a trick #77, xDD):
    I use this plugin to suggest music listenings to my visitors. I found it very helpful but I wanted to list a random selection, not just the latest. I added a ORDER BY RAND() to the Sql envolved queries just before the LIMIT statement. This way visitors will find different suggestions each time they reload de page.

    I think It would be nice if you included a check box to automate this behaviour from the options panel.

    Thanks for this plugin!!

  33. Jan on June 26th, 2009

    That’s one cool idea! I will implement this for the next version of the plugin.

  34. Jay on July 8th, 2009

    I’d like a thumbnail with this plugin!

  35. [...] meinen neuen Gästen das Herumstöbern zu erleichtern, habe ich ein kleines Plugin aktiviert (Must Read Posts, nach Hinweisen in den dortigen Kommentaren etwas angepasst), das in der Seitenleiste unter [...]

  36. Pär on July 25th, 2009

    Hi and thanx for a great plugin that I have used for a while. I have a suggestion for improvemnt though. I would like to show the latest ‘must-read’ posts and not have to change the custom field to remove old ones. Ie: if I put 5 as the limit I would like the plugin to show only the 5 latest post with the ‘must-read’ flag, sorted with the latest one on top. I guess this is a rather simple sql-thing an if I manage to tweak it myself I will let you know. Thanx again!

  37. Alejandro on September 25th, 2009

    This is an excellent plugin. I use it as a Widget. I did a little modification to the code in order to show the date of the post in the must read list.

    I would like you to help me. I would like to use it twice in my blog. Right now I am using it as “What I recommend”, but also I want to add another list like “About some theme”.

    Once I use it for the first list, it disappear from the Widgets Dashboard.

    Thanks in advance.

  38. Jan on September 25th, 2009

    Alejandro, I’m afraid, I don’t have a clue how to load the plugin twice. This seems to be a generic WP issue that you can’t use a plugin twice with different settings. I know some plugins have coded around this but I have no idea how it works.

    Cheers,
    Jan

  39. Alejandro on September 25th, 2009

    Hi Jan,

    I resolved it making a /must-read-posts_2 folder in /plugins, and then copy your .php into it but replacing every “mustread” to “mustread_2″.

    It is working just fine.

  40. Doug on January 14th, 2010

    I write some programming but I am not a PHP programmer. I am using your plugin but I have one hitch. The name of the post has the text formating showing up in the sidebar. Can you help me with some sample code to parse it out? If I could parse the string into an array and then grab the section that I need and throw it back into the correct variable..That’s what I am thinking. Suggestions?

    I need this to show up….
    Discover Muhammad Ali’s tricks for rolling with the punches

    But I am getting this…
    Discover Muhammad Ali’s tricks for rolling with the punches

  41. Jan on January 14th, 2010

    Doug, I think the formatting got lost in the comment. But you may want to have a look at this PHP function:

    http://php.net/manual/en/function.strip-tags.php

    This will strip all HTML code from a string.

    Cheers,
    Jan

Leave a reply