Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 1.33   Updated Monday, July 6th, 2009 at 6:18pm

Drop-Down Post List Plugin for WordPress

This plugin allows you to easily display drop-down boxes containing the posts for specified categories (or all categories). You can use this plugin by entering the trigger text in a post or page, or by adding the function call directly to your theme files. You can display as many drop-down boxes as you like, and you have a choice between a standard select box (with button), or a ‘jump menu’ (as the visitor clicks on a post, they will immediately be taken to that page without having to click a button). Other options are also available.

Download

  If you have found this page useful, please consider donating. Thanks!

Demo

This is a generated drop-down post list, listing the posts of a particular category:

Topic: WordPress Plugins and Mods


Installation

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin under the DDPostList options page

Usage

There are two ways you can use this plugin.

Note: In both examples below, replace # with the category ID you want to list posts from, or use the word all to display posts from all categories.

1) In a post or page:

<!-- ddpl # -->
<!-- ddpl all -->

2) In a template file::

<?php echo ddpl_list(#); ?>
<?php echo ddpl_list('all'); ?>

Change Log

  • 07-09-09 Version 1.33 – Added method to display posts from all categories. Changed the way the WP version was being detected for calls to the database.
  • 02-17-09 Version 1.32 – Small change to produce valid xhtml when using more than one drop-down on a page
  • 08-12-08 Version 1.31 – Small change to produce valid xhtml
  • 09-27-07 Version 1.3 – Updated to work with WordPress 2.3. Added ‘Load Default Options’ button
  • 08-01-07 Version 1.2 – Option added to specify default option in list
  • 07-29-07 Version 1.1 – More options added
  • 07-28-07 Version 1.0 – First release

Modifications

The code this plugin generates is fairly plain (no special formatting), but to make customization easy, the form has been assigned a CSS class: ddpl-form

For example, if you would like to set the width of the select field, add this code to your theme’s style sheet:

form.ddpl-form select { width: 200px; }

Options

Here are the current options available (found under the DDPostList options page)

Form Type – You can choose to have the plugin generate a ‘jump menu’, or a traditional list with a submit button

Default Option – If entered, this is the first option that will show up in the list (does not link to anything)

Button Text – If using a traditional list, this is the button text

Sorting Method – You can choose to sort by post date (ascending or descending), or post title

Post Limit – This allows you to define a limit for the number of posts in the list (0 for no limit)

Add Before Form – Code added here will be displayed before the generated form

Add After Form – Code added here will be displayed after the generated form

Add Before List – Code added here will be displayed before the list

Add After List – Code added here will be displayed after the list

  1. hey there, thanks for the plugin, really cool!
    i seem to have a couple problems, though, and it’s been mentioned once. the posts are doubling up, sometimes tripling on the list. also, in firefox it doesn’t seem to list all the posts and I don’t have a limit set. otherwise it works great! any help is much appreciated and thanks again for a great plugin!

  2. Nice plugin. Thanks for shared.

  3. The problem seems to be in the limits of bb javascript. Sorry to bug.

  4. This is exactly what I needed to make sure my visitors get past the first page (and even to the bottom of it). One small quirk (and you’re not alone in this): on my Blackberry, the list shows up, I can set the page, but there’s no way that I can find to click or anything to go there. I know some plugins can make this happen, but I have no idea how. Do you?

  5. 97
    mak sev

    trying to put this in the sidebar

    wp 3.8.4 theme atahualpa

    its not displaying

  6. Mandy, Yuna: try combining this with the Exec-PHP plug-in and a text widget. Works for me in WordPress 2.8.3.

    What I’d love is a complement to this plug-in that presents recent *comments* as a dropdown!

  7. hey? this doesnt work!!!

    why not????

    i am using wp 2.82…..

  8. 94
    soleman

    Can you put in a custom field so a specific category drop down list shows up on specific posts?

  9. 93
    nosharara212

    Hello. I’d like my category archive pages to display simple, alphabetical links to posts within the category instead of large post titles with excerpts (or full posts).

    Where can I insert the code for the 10 different category pages?
    Help?

  10. 92
    Yuna

    Any way to put this on the sidebar other than editing template files?

  11. i couldn’t make it work on WP 2.82 last version! any suggestions?

  12. 90
    nosharara212

    Hi,

    I have a couple of categories:

    http://www.myblog.com/category/news/
    http://www.myblog.com/category/google/
    http://www.myblog.com/category/books/

    News is cat ID 1, Google 2, Books 3.

    I want the menu to appear at the top of each of those pages, but can’t exactly find those category pages (they are not under pages in wordpress), how can I do that?

  13. 89
    Scorpio84

    i made it work after changing some php code

  14. 88
    Scorpio84

    I am using WP 2.7.1 and the latest plugin version

  15. Hi can you please check my site. the ‘jump’ is not working and its showing all posts multiple times…

  16. 86
    Mandy

    How would I put this inside a widget?

  17. Thanks for the update. But what about excluding 1 or 2 catergories?

  18. Version 1.33 Released

    In addition to choosing which category to display posts from, I have added a method to display posts from all categories. See the usage instructions above.

    I have also modified the code used to determine the version of WordPress (this is needed because the database structure code changed greatly with 2.3). Some security plugins prevented the old method from being used.

    This version has been tested, and works in the latest release of WordPress – 2.8

    Enjoy!

  19. 83
    Cindy

    I have 2.8 installed and can’t get the plugin to work.I’m able to activate it etc, but it doesn’t create the list.

    I’ve tried JK’s solution, but I can’t seem to get that to work either. I get Parse error: syntax error, unexpected T_STRING.

    I would appreciate it to no end if this could work for 2.8!
    Thanks!

  20. Hi there

    I’m looking for a way to select multiple posts and then show the selected posts on a single page.

    For example to make 3 dropdown selectboxes each one showing the posts of one category. After selecting a post in each selectbox and pressing a button or something the selcted posts should show one after the other.

    Is this possible with the Drop-Down Post List Plugin?

    Thanks!! Floris

  21. Ok – I also had the same problem after upgrading to 2.8. I debugged and the issue is with $wp_version. After upgrade, this variable somehow is less than 2.3 and as a result, it gets into 2.3 section. So I moved > 2.7 section of the code above the if condition and I commented the below if condition. Anyway here is the code snippet around my changes:

    function ddpl_list($catID) {

    global $wpdb, $wp_version;

    $ver = (float)$wp_version;

    $ddpl_type = get_option(’ddpl_type’);
    $ddpl_button = trim(get_option(’ddpl_button’));
    $ddpl_default = stripslashes(trim(get_option(’ddpl_default’)));
    $ddpl_sort = get_option(’ddpl_sort’);
    $ddpl_limit = (int)get_option(’ddpl_limit’);
    $ddpl_before_form = stripslashes(get_option(’ddpl_before_form’));
    $ddpl_after_form = stripslashes(get_option(’ddpl_after_form’));
    $ddpl_before_list = stripslashes(get_option(’ddpl_before_list’));
    $ddpl_after_list = stripslashes(get_option(’ddpl_after_list’));

    $t_out = ”;

    $table_prefix = $wpdb->prefix;

    $sort_code = ‘ORDER BY post_date DESC’;
    switch ($ddpl_sort) {
    case ‘date_desc’:
    $sort_code = ‘ORDER BY post_date DESC’;
    break;
    case ‘date_asc’:
    $sort_code = ‘ORDER BY post_date ASC’;
    break;
    case ‘title’:
    $sort_code = ‘ORDER BY post_title ASC’;
    break;
    }

    $limit_code = ”;
    if ($ddpl_limit > 0) {
    $limit_code = ‘ LIMIT ‘ . $ddpl_limit;
    }

    $post_list = (array)$wpdb->get_results(”
    SELECT ID,
    post_title,
    post_date
    FROM {$table_prefix}posts, {$table_prefix}term_relationships, {$table_prefix}term_taxonomy
    WHERE {$table_prefix}posts.ID = {$table_prefix}term_relationships.object_id
    AND {$table_prefix}term_relationships.term_taxonomy_id = {$table_prefix}term_taxonomy.term_taxonomy_id
    AND {$table_prefix}term_taxonomy.taxonomy = ‘category’
    AND {$table_prefix}term_taxonomy.term_id = {$catID}
    AND post_status = ‘publish’
    AND post_type != ‘page’
    {$sort_code}
    {$limit_code}
    “);

    /*
    if ($ver get_results(”
    SELECT ID, post_title, post_date
    FROM {$table_prefix}posts, {$table_prefix}post2cat
    WHERE {$table_prefix}posts.ID = {$table_prefix}post2cat.post_id
    AND {$table_prefix}post2cat.category_id = {$catID}
    AND post_status = ‘publish’
    AND post_type != ‘page’
    {$sort_code}
    {$limit_code}
    “);

    } else { // post 2.3

    $post_list = (array)$wpdb->get_results(”
    SELECT ID,
    post_title,
    post_date
    FROM {$table_prefix}posts, {$table_prefix}term_relationships, {$table_prefix}term_taxonomy
    WHERE {$table_prefix}posts.ID = {$table_prefix}term_relationships.object_id
    AND {$table_prefix}term_relationships.term_taxonomy_id = {$table_prefix}term_taxonomy.term_taxonomy_id
    AND {$table_prefix}term_taxonomy.taxonomy = ‘category’
    AND {$table_prefix}term_taxonomy.term_id = {$catID}
    AND post_status = ‘publish’
    AND post_type != ‘page’
    {$sort_code}
    {$limit_code}
    “);

    }

    */

    if ($ddpl_type == ‘jump’) {

    $t_out .= ”;
    $t_out .= $ddpl_before_list;
    $t_out .= ”;

    if ($ddpl_default != ”) {
    $t_out .= ” . $ddpl_default . ”;
    }

    foreach ($post_list as $p) {
    $t_out .= ‘ID) . ‘”>’ . $p->post_title . ”;
    }

    $t_out .= ”;
    $t_out .= $ddpl_after_list;
    $t_out .= ”;

    } else {

    $catname = get_cat_name($catID);
    $t_out .= ”;
    $t_out .= $ddpl_before_list;
    $t_out .= ”;

    $t_out .= ‘‘ . $catname . ‘‘;
    foreach ($post_list as $p) {
    $t_out .= ‘ID) . ‘”>’ . $p->post_title . ”;
    }

    $t_out .= ”;
    $t_out .= $ddpl_after_list;
    $t_out .= ”;

    }

  22. It has stopped working. I am not sure how long ago. I have had to disable it, as it is no good saying “select post” when none of the posts are listed. How do i get it to work again? Are there plugins that are not compatible? Which ones? I am running Wordpress 2.7.1. Any help would be appreciated.

  23. I’m also having problems getting it to work in wp 2.7.1
    I’ve set it all up ok but the code

    with the number of the category included just displays on the page as a bit of code and not the jumpdown menu.

  24. 78
    Chirag

    HI

    How can I install this plugin in to the wordpress 2.7.1.

    pls help me to install this plugin

  25. 77
    James

    Hi again,

    Found it. It was staring me in the face via the settings options. Some times I make life too hard for myself.

    Thanks again for the great plugin.

  26. 76
    James

    Hi,

    Excellent plugin – thanks for sharing.

    In the site I am creating I would like to change the (Select a Post0 to (Select a Profile). I tried to edit the plugin by doing the following:

    add_option(’ddpl_default’, ‘(select a profile)’);

    and

    update_option(’ddpl_default’, ‘(select a profile)’);

    but this does not seem t have any effect.

    If you could help me out here, it would be much appreciated.

    Thanks :)

  27. 75
    Trish

    Does anyone know how I can make it work with all categories instead of defining a specific category?

  28. AWESOMELY easy add-in – THANKS !

    But I cant seem to get it to sort alphabetically (by title).

    No matter how many times I go into the options, it doesnt seem to retain it. Any ideas or dependencies?

  29. How can i show ALL category? Developer please response. Thanks

  30. I just installed this, but I don’t see a DDPostList options page. Did I miss something?

  31. Hey there, thank you very much for the plugin!
    There is one question though:
    I’m using more than one dropdownmenu, and I need the Default Option to be the Category name. how could i manage the Default Option for each dropdownmenu i use separatly?

  32. Allison: The option allows you to specify a category ID – not a user ID. I will keep it in mind for a future update though.

  33. Apparently the plugin will not work by using the ID associated with the user, ergo: Admin (1)

    If this were possible, we could make use of this plugin, but unfortunately without this functionality we must keep searching.

    If however you could either revise the plugin to work with User ID numbers while remaining in a pulldown menu, we would be happy to supply an ad spot for you on SmArgus for 2 months.

  34. Update: The plugin also does not work within an existing table.

  35. February 23rd, 2009

    Hello, this is just what we have been searching for on our multiple contributor bog. Thank you for taking the time to make this plugin.

    However, when we plug in the ID numbers for administrator level accounts it does not work. This presents a problem as both admin accounts are also contributors.

    Is there perhaps a workaround for this?

    Cordially,

    Allison Bricker

  36. Rick: Unpacking the plugin package? The plugin is just a single file you rename to PHP then upload. I do not believe that the error you mentioned could be caused by the plugin itself. There are no archives involved.

  37. 65
    Rick

    WP 2.71 – Thesis 1.4.2

    Unpacking the plugin package

    Incompatible archive: PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature

    Installation Failed

  38. Version 1.32 Released

    This version fixes a html validity error when more than one drop-down is used on the same page.

  39. I know you state that this plugin validates but I’m finding that it doesn’t. My site is XHTML 1.0 Strict and the DDPL is the only thing stopping me from being valid. I love this plugin so I’m hoping you’ll be updating it SOON!!! PLEASE!

  40. Thanks.. just what we needed. You can see your plugging in action here: http://www.radioinox.com

  41. Why we cannot add more than one category? Can we put this option?

  42. we should be able to add more than 1 category…

  43. 59
    Saulo Benigno

    Does it work with WP 2.7?

    Thanks.

  44. 58
    Scott

    unless…..the small recent upgrade from WP 2.6.3 to 2.6.5 broke it? That about the only thing that changed, and that was only 2 new files I think.

  45. 57
    Scott

    OK – I’m a bit confused. Last week it was working fine, now it isn’t! The drop-down list does not show anything. I restarted the plugin – no luck. I’m not getting errors or anything, just nothing in the drop down. Any ideas? My syntax has not changed. Hmmm.

  46. 56
    EgitimTUBE

    Thanks Very Good

  47. 55
    Karl

    Great plugin,

    How would i go about showing posts from ALL categories (i have over 40!) in the dropdown?

    Thanks

  48. Great.. works excellent for me.

  49. when i put in my sidebar, i don’t see anything post can i click in drop down menu. What’s problem with this..??

    if i change to that’s is same..

    if I deleted display

    “Warning: Missing argument 1 for ddpl_list(), called in /home/****/public_html/wp-content/themes/********/l_sidebar.php on line 25 and defined in /home/****/public_html/wp-content/plugins/dd-drop-down-post-list.php on line 168″

  50. 52
    kroma

    hmm some of my plugins caused problems … it works now

  51. 51
    kroma

    it doesn’t work for me :( if i try to enter in in the template or just enter it on page it doesn’t work :/. only shows me (selec a post) in menu

  52. 50
    norbesz

    sorry! there’s no problem :) if i log out (or see the site from an other browser) everything works normally
    thanks again for the plugin! :)

  53. 49
    norbesz

    hi! thanks for this great plugin. but i have a problem. it doubles the posts in the list :S
    example here:
    http://cserkesz.hu/~mukso205/?page_id=267
    i use another 2 category plugin, i think it will be the problem, but i want all of them :) (if i turn off the plugins the mistake still remains)
    the plugins are : folding categories for wordpress and front page excluded categories
    any idea?

  54. 48
    cartmanffc

    any chances you could make the plugin for a drop down menu of authors in a similar way this plugin works

  55. I REALLY APRECIATE, ITS A GREAT PLUGIN, WAS HELP ALOT
    THE SAMPLE ITS BELOW
    REALMENTE LO APRECIO ES UN GRAN PLUGIN ME AYUDO MUCHISIMO LA MUESTRA ES ESTA
    http://soylibreencristo.com/?page_id=457

  56. 46
    Devin

    Thank a TON for the update!

  57. Nice and simple plugin :) Thanks a lot for sharing!

  58. can this plugin be change to list pages as a drop down?

  59. Version 1.31 has been released. It is just a small code change to produce valid xhtml.

    Stout: I tested, but it showed my private posts just fine.

  60. 42
    Stout

    Hello !
    This great plugin doesn’t show the private posts, even when logged…
    Any Ideas on how to enable that ?
    Thanks !

  61. I have a main category id 15 with no posts under it, but it has subcategorys with posts. How can I make putting id 15 show all posts from the subcategorys.

  62. 40
    Devin

    Hello. I love this plug-in, its great for webcomics, BUT I also want to use this with a W3C xhtml 1.0 Valid website. When I add this plug-in My website is no longer valid xhtml. I think the error lies in the plug-in itself, as this page generates the same kind of validation error because it has the plug-in.

    http://validator.w3.org/

  63. Despite accurate settings in admin, some of my recent posts are not displayed at all, and some old ones are mixed into the most recent posts. Wonder what I’m doing wrong… – running latest Wordpress, maybe that’s the problem? – Beautiful plugin, though – help greatly appreciated!

  64. What if I want this to work on all categories? how can I make it work with all categories?

  65. my bad sorry, just found it under Settings. Great plugin btw thanks

  66. sorry but how do i set the options for the drop down? I’ve activated the plugin but I can’t see any option settings?

  67. I want to display a non-dropdown list of every post in one category on a page is this possible?

  68. Sorry, but for I reveiving Parse error: syntax error, unexpected ‘;’, expecting ‘)’ , I’ve checked everythings.. Could somebody help?

  69. 33
    cobb

    Thanks for this. I’m using wordpress 2.5.1 and whilst the drop down shows in the post I don’t get any entries. Any suggestions much appreciated as I really like this plugin.

  70. Thanks a lot for this plugin….

  71. Here is a workaround for my desire to have a single tag list all posts.
    1. Install and activate DDPL
    2. Create a new, dedicated category for this sole purpose
    3. Add all posts to this category
    4. Download, install and active one of many plugins designed to hide categories. Here’s a start: http://www.google.com/search?q=hide+category+plugin
    5. Hide the new category
    6. Use the DDPL tag to call the new category (i.e.
    <?php echo ddpl_list(6); ?> )
    You should be good to go.

  72. Hi,

    I’ve been trying to get your plugin working here:
    http://wirelife.co.uk/?page_id=7

    But it doesn’t seem to be working. If you could help me i’d be very grateful.

    Regards,
    Davthalas

  73. I can change the list name, or what’s supposed to show in the box first… such as (Choose One)… but nothing shows there. It is always just the first item / page that shows up. How can I make the first thing be the (Choose One)?

  74. Is there anyway to change the List name

    For example the defautlt is set to “Select a Post” I tried searching in the plug in to change to a different text like “more posts here”

    But cant figure out how..

  75. Let me add my voice to those asking for a way to use this plugin to display all posts from all categories. That would be a huge help!

  76. Was I-O’s question ever answered? I have the same question. What happened to support for this plug in.
    I would like to display the drop down list at the bottom of my individual category pages.

    EG// say I have 3 categories Parties, Recipes and Events when you click on these the first 5 posts for each are displayed and at the bottom is the drop down list for all of them…I tried pasting it into category.php and got a blank page.

  77. Hi, when I try to download the plugin on this page, it doesn’t work

  78. Is there a way to set a variable for category ID so you can inset the code in the single post template and it automatically checks the category ID and displays those posts in the drop down?

  79. I can’t get the “Default Option” to show up on the form.
    Any ideas why?

  80. 22
    reagan

    Does it support Pages?I want to have a dropdown list for PAGES too.

  81. i got a problem when i activate this plugin….

    when i activate this plugin, visual editor tab will be disabled in my write page….. what can i do????

  82. 20
    Alvin

    Hi,

    I’m very new at wordpress.. how do you make it appear like what’s on http://www.hernadezlife.com? Its basically sitting on the right hand sidebar with a title called All Entries.

    Thanks

  83. the code form.ddpl-form select { width: 200px; } doesn’t work

  84. 18
    Johnny

    sorry…forgot to wrap the code

    <?php echo ddpl_list(#); ?>

  85. 17
    Johnny

    pasting in

    gives me a syntax error?

    Parse error: syntax error, unexpected ‘;’, expecting ‘)’ in….

    i am pasting it into my sidebar.php page

    weird?

  86. I realize that it is possible to setup several of your tags to display all posts from all categories,… but can you setup just one tag to display all posts from all categories?

    Sorry,… I don’t believe that I was specific enough with my previous post on this subject.

  87. Is it possible to setup the <?php echo ddpl_list(#); ?> tag so that it will automatically follow the appropriate category such as the <?php the_category(', ') ?> tag to eliminate manual insertion?

  88. Karin: It is a demo, yes.

  89. 13
    Karin

    Isn’t wat is shown under ‘demo’ here above not a demo?

  90. Is it possible to display ALL posts from ALL categories?

  91. Does this drop down menu include the sub-categories as well? For example, let say I have “colors” with the sub category of “red”/”blue”/”orange”, will this plugin list the subcategories in the parent category?

  92. 10
    eric

    Great plugin! Thank you once again!!

    Ditto what Corrine said. It would be great if the menus could display links to posts OR links to categories/subcategories.

  93. 9
    goodhand

    excellent solution, thanks so much.

  94. Thanks – this worked great and I need things to be very simple. I did it!

  95. This is exactly what I was looking for. Very easy to use and works with no problems. I’m trying to create a static home page and this will help a lot. Thanks for the plugin.

  96. Thanks. I really like your plugins. I just upgraded to WordPress 2.3 and was pleased to see that your plugins were compatible. This was not the case with some of my other plugins – as a result, I had to ditch a few of them and I replaced one of them with this one.

  97. Version 1.3 Released

    This update adds support for WordPress 2.3, and will also still work in 2.1 and 2.0.

  98. Is it possible to have a version to display link categories?

    I guess that would require a lot of extra work…. Just a thought.

  99. How do I display all posts from all categories? Can you post some code about that?

  100. 2
    gentoo7

    this is awesome, thanks a lot!

  101. Sounds good. But a demo would be nice :)
    I’m gonna try it out anyway.

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.