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. thanks admin

  2. 133
    Roland

    Hello
    its a very good script. but it shows only 5 posts in the list. the limit is set to 0
    thanks
    Roland

  3. Why can’t I get this to work?

    URL http://waterworks-lamson.com/wordpress/authorized/

    Can someone Help Me Please I’d really appreciate it big time!
    Form Type – Jump Menu
    Sorting Method – By title
    Post Limit – 0

    Permissions – 755

  4. Hello!

    And that change in the code, so that when you choose (select a post) opens the main page of your site?

    thanks

  5. Hello!

    And that change in the code, so that when you choose (select a post) opens the main page of your site?

  6. 129
    James

    Is there any way of adding the category name to the drop down list? So it would be for example…

    Post 1 title (Category 2 Name)
    Post 2 title (Category 1 Name)

    If so how?

  7. Hi Dagon,

    I’m running WordPress 3.0. and Drop-Down Post List v1.33

    I looks good the drop down list looks good but when I hit the go button it won’t go to the post (link doesn’t work) Any ideas?

    http://waterworks-lamson.com/wordpress/authorized/

    The settings for the plug in are as follows:

    Form Type – List with button
    Button Text – go
    Sorting Method – By title
    Post Limit – 0

    That’s all the settings I have set please let me know what you think.

    Thank you!
    Brent

    Here is the php file code in case you need it.

    
    
     
    
    <?php
    /*
    Plugin Name: Drop-Down Post List
    Plugin URI: http://www.dagondesign.com/articles/drop-down-post-list-plugin-for-wordpress/
    Description: Generates a drop-down list of posts for a particular category.
    Author: Dagon Design
    Version: 1.33
    Author URI: http://www.dagondesign.com
    */
    
    $ddpl_version = '1.33';
    
    // Setup defaults if options do not exist
    add_option('ddpl_type', 'jump'); 
    add_option('ddpl_button', 'View'); 
    add_option('ddpl_default', '(select a post)'); 
    add_option('ddpl_sort', 'date_desc'); 
    add_option('ddpl_limit', 0); 
    add_option('ddpl_before_form', ''); 
    add_option('ddpl_after_form', ''); 
    add_option('ddpl_before_list', ''); 
    add_option('ddpl_after_list', ''); 
    
    
    function ddpl_add_option_pages() {
    if (function_exists('add_options_page')) {
    add_options_page('Drop-Down Post List', 'DDPostList', 8, __FILE__, 'ddpl_options_page');
    }		
    }
    
    
    function ddpl_options_page() {
    
    global $ddpl_version;
    
    if (isset($_POST['set_defaults'])) {
    echo '<div id="message" class="updated fade"><p><strong>';
    
    update_option('ddpl_type', 'jump'); 
    update_option('ddpl_button', 'View'); 
    update_option('ddpl_default', '(select a post)'); 
    update_option('ddpl_sort', 'date_desc'); 
    update_option('ddpl_limit', 0); 
    update_option('ddpl_before_form', ''); 
    update_option('ddpl_after_form', ''); 
    update_option('ddpl_before_list', ''); 
    update_option('ddpl_after_list', ''); 
    
    echo 'Default Options Loaded!';
    echo '</strong></p></div>';
    
    } else if (isset($_POST['info_update'])) {
    
    echo '<div id="message" class="updated fade"><p><strong>';
    
    update_option('ddpl_type', (string)$_POST["ddpl_type"]); 
    update_option('ddpl_button', (string)$_POST["ddpl_button"]); 
    update_option('ddpl_default', (string)$_POST["ddpl_default"]); 
    update_option('ddpl_sort', (string)$_POST["ddpl_sort"]); 
    update_option('ddpl_limit', (int)$_POST["ddpl_limit"]); 
    update_option('ddpl_before_form', (string)$_POST["ddpl_before_form"]); 
    update_option('ddpl_after_form', (string)$_POST["ddpl_after_form"]); 
    update_option('ddpl_before_list', (string)$_POST["ddpl_before_list"]); 
    update_option('ddpl_after_list', (string)$_POST["ddpl_after_list"]);
    
    echo 'Configuration Updated!';
    echo '</strong></p></div>';
    
    } ?>
    
    
    
    
    <div class=wrap>
    
    <h2>Drop-Down Post List v<?php echo $ddpl_version; ?></h2>
    
    <p>For information and updates, please visit:<br />
    <a href="http://www.dagondesign.com/articles/drop-down-post-list-plugin-for-wordpress/">http://www.dagondesign.com/articles/drop-down-post-list-plugin-for-wordpress/</a></p>
    
    
    <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
    <input type="hidden" name="info_update" id="info_update" value="true" />
    
    
    <h3>Options</h3>
    <table width="100%" border="0" cellspacing="0" cellpadding="6">
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Form Type</strong> &nbsp; 
    </td><td align="left">
    <input name="ddpl_type" type="radio" value="jump" <?php if (get_option('ddpl_type') == "jump") echo "checked='checked'"; ?> />&nbsp;&nbsp; Jump menu<br />
    <input name="ddpl_type" type="radio" value="list" <?php if (get_option('ddpl_type') == "list") echo "checked='checked'"; ?> />&nbsp;&nbsp; List with button<br />
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Default Option</strong> &nbsp; 
    </td><td align="left">
    <input name="ddpl_default" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars(get_option('ddpl_default'))) ?>"/>
    <br /><i>If entered, this will be the default list option (does not link to anything)</i>
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Button Text</strong> &nbsp; 
    </td><td align="left">
    <input name="ddpl_button" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars(get_option('ddpl_button'))) ?>"/>
    <br /><i>Button is only shown if using 'list with button' form type</i>
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Sorting Method</strong> &nbsp; 
    </td><td align="left">
    <input name="ddpl_sort" type="radio" value="date_desc" <?php if (get_option('ddpl_sort') == "date_desc") echo "checked='checked'"; ?> />&nbsp;&nbsp; By date - newest first<br />
    <input name="ddpl_sort" type="radio" value="date_asc" <?php if (get_option('ddpl_sort') == "date_asc") echo "checked='checked'"; ?> />&nbsp;&nbsp; By date - oldest first<br />
    <input name="ddpl_sort" type="radio" value="title" <?php if (get_option('ddpl_sort') == "title") echo "checked='checked'"; ?> />&nbsp;&nbsp; By title<br />
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Post Limit</strong> &nbsp; 
    </td><td align="left">
    <input name="ddpl_limit" type="text" size="5" value="<?php echo get_option('ddpl_limit') ?>"/>
    <br /><i>Limits the number of posts in the list (0 = no limit)</i>
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Add Before Form</strong> &nbsp; 
    </td><td align="left">
    <textarea name="ddpl_before_form" cols="40" rows="4"><?php echo stripslashes(htmlspecialchars(get_option('ddpl_before_form'))) ?></textarea>
    <br /><i>Code to display before the form</i>
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Add After Form</strong> &nbsp; 
    </td><td align="left">
    <textarea name="ddpl_after_form" cols="40" rows="4"><?php echo stripslashes(htmlspecialchars(get_option('ddpl_after_form'))) ?></textarea>
    <br /><i>Code to display after the form</i>
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Add Before List</strong> &nbsp; 
    </td><td align="left">
    <textarea name="ddpl_before_list" cols="40" rows="4"><?php echo stripslashes(htmlspecialchars(get_option('ddpl_before_list'))) ?></textarea>
    <br /><i>Code to display before the list</i>
    </td></tr>
    
    <tr valign="top"><td width="35%" align="right">
    <strong>Add After List</strong> &nbsp; 
    </td><td align="left">
    <textarea name="ddpl_after_list" cols="40" rows="4"><?php echo stripslashes(htmlspecialchars(get_option('ddpl_after_list'))) ?></textarea>
    <br /><i>Code to display after the list</i>
    </td></tr>
    
    </table>
    
    <div class="submit">
    <input type="submit" name="set_defaults" value="<?php _e('Load Default Options'); ?> &raquo;" />
    <input type="submit" name="info_update" value="<?php _e('Update options'); ?> &raquo;" />
    </div>
    
    </form>
    </div><?php
    }
    
    
    
    function ddpl_list($catID) {
    
    $all_cats = FALSE;
    if (strtolower(trim($catID)) == 'all') {
    $all_cats = TRUE;
    }
    
    
    global $wpdb;
    $tp = $wpdb->prefix;
    // Currently using a work-around for the version system
    // determines if pre or post 2.3 from wp_term_taxonomy 
    $ver = 2.2;
    $wpv = $wpdb->get_results("show tables like '{$tp}term_taxonomy'");
    if (count($wpv) > 0) {
    $ver = 2.3;
    }
    
    
    $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;
    }
    
    
    if ($ver < 2.3) {
    
    $cat_sel_code = ' ';
    if (!$all_cats) {
    $cat_sel_code = " AND {$table_prefix}post2cat.category_id = {$catID} ";
    }
    
    $post_list = (array)$wpdb->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 
    {$cat_sel_code} 
    AND post_status = 'publish' 
    AND post_type != 'page' 
    {$sort_code} 
    {$limit_code} 
    ");
    
    } else { // post 2.3
    
    $cat_sel_code = ' ';
    if (!$all_cats) {
    $cat_sel_code = " AND {$table_prefix}term_taxonomy.term_id = {$catID} ";
    }
    
    $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' 
    {$cat_sel_code}
    AND post_status = 'publish' 
    AND post_type != 'page' 
    {$sort_code} 
    {$limit_code} 
    ");
    
    }
    
    
    // use random ID when showing all
    if ($all_cats) {
    $randstr = '';
    $maxchar = 8;
    $chars = str_shuffle('abcdef1234567890');
    $len = strlen($chars);
    for ($i = 0; $i < $maxchar; $i++) {
    $randstr .= $chars[mt_rand(0, $len-1)];
    }
    $catID = $randstr;
    }
    
    
    if ($ddpl_type == 'jump') {
    
    $t_out .= '<form class="ddpl-form" name="catform' . $catID. '" id="catform' . $catID. '" action="">';
    $t_out .= $ddpl_before_list;
    $t_out .= '<select name="jumpMenu' . $catID. '" id="jumpMenu' . $catID. '" onchange="MM_jumpMenu(\'parent\',this,0)">';
    
    if ($ddpl_default != '') {
    $t_out .= '<option value="">' . $ddpl_default . '</option>';
    }
    
    foreach ($post_list as $p) {
    $t_out .= '<option value="' . get_permalink($p->ID) . '">' . $p->post_title . '</option>';
    }
    
    $t_out .= '</select>';
    $t_out .= $ddpl_after_list;
    $t_out .= '</form>';
    
    } else {
    
    $t_out .= '<form class="ddpl-form" name="catform' . $catID. '" id="catform' . $catID. '">';
    $t_out .= $ddpl_before_list;
    $t_out .= '<select>';
    
    foreach ($post_list as $p) {
    $t_out .= '<option value="' . get_permalink($p->ID) . '">' . $p->post_title . '</option>';
    }
    
    $t_out .= '</select>';
    $t_out .= $ddpl_after_list;
    $t_out .= '<input type="button" value="' . stripslashes(htmlspecialchars($ddpl_button)) . '" onClick="MM_jumpMenu(\'parent\', this.form.elements[0], 0)"></form>';
    
    }
    
    
    return $ddpl_before_form . $t_out . $ddpl_after_form;
    }
    
    
    
    function ddpl_check($content) {
    
    // remove P tags around html comments (comment out to disable)
    $content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content); 
    
    $results = array();
    
    preg_match_all("/<!--\s?ddpl\s?(.*)\s?-->/", $content, $results);
    
    $i = 0;
    foreach ($results[0] as $r) {
    $content = str_replace($r, ddpl_list($results[1][$i]), $content);
    $i++;
    }
    
    return $content;
    }
    
    
    
    function ddpl_head() {
    echo "
    <script type=\"text/javascript\">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+\".location='\"+selObj.options[selObj.selectedIndex].value+\"'\");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    ";
    }
    
    
    add_action('admin_menu', 'ddpl_add_option_pages');
    add_filter('the_content', 'ddpl_check');
    add_action('wp_head', 'ddpl_head');
    
    ?>
    

  8. 126
    rainer

    ass

  9. We supply all kinds of moncler boots,moncler bags,moncler coats,moncler jackets,moncler T-shirt,moncler vest and so on.We have got a good reputation pf our products with top quality and good price.We sincerely look forward to futher cooperation with you for mutual benefits.We are sure that you will find working with us is a pleasant, time-saving and profitable experience. Please feel free to contact us if you have any questions.Our website is http://www.newlyapparel.com.

  10. 124
    Matt

    Cool script. It would great if I was able to pass an argument to dppl_list to create the default choice. I’m trying to make a list for each of my cateogries and their needs to be a default vaulue so people know where they are.

  11. 123
    Ken

    does this work with a mobile site?

  12. This is fantastic and is SO very close to what I need. What I am actually looking for is a way to have this function be a part of a custom write panel. Basically, I’d like the author to be able to be able to write a new post and have a dropdown that lists all the posts in a certain category (or post type) so that they can easily link the two together. Can you provide any help on this kind of feature?

  13. The duplicate listing of some posts occurs when the posts are listed under multiple categories. I’m not sure how to fix that.

  14. Found it works with the CatID number but not the ID name.

    Good enough!

    Thanks!

    Kermit

  15. I’m trying to use this but when I specify the category I don’t get any list in the dropdown – just the “Select Post” entry.

    Does this work with WP 2.9.2?

    Kermit

  16. I can define the width to some degree but as soon as I use it or navigate away from the original call it blows the width

  17. Thanks a lot,very helpful

  18. 116
    fum

    Hi, first thank you for share your work, I enjoy your plugin.
    I have an issue that others users have got too. The plugin works fine but the same post name appears two or three times in the list, any sugestion?
    Thank you again,

    fum.

    fum.

  19. 115
    Dstar

    Thanks. But the posts that display have twice title with wordpress 2.7.1 Please Helps!

  20. This looks like exactly what I need, but ….

    Can I get this to work with tags instead of categories?

    I’m trying to have a drop-down list of neighborhoods in Tallahassee (over 1,000 of them) from articles that I’ve written and tagged with the neighborhood name.

    Thanks.

  21. Okay, I can define the width to some degree but as soon as I use it or navigate away from the original call it blows the width.

  22. I’m trying to test this for a friend and my one issue is that I can’t adjust the width. I’ve used your css in more ways than one and the darn thing stays exactly the same width at all times.

  23. Answered own question. My page is loop-driven the page text never displays. Trigger needs to be in template. Works.

  24. Doesn’t seem to work with 2.9.1. Installed, options chosen, trigger text put in page. Nothing appears. What is needed to make it appear?

  25. 109
    adnan

    hi
    i have uploaded and activated the plugin when i use this code in page

    i get the same output no dropdown
    im using a custom theme i have to make any changes theme side?

  26. 108
    echio

    So would it be possible to use get_cat_id() function in
    to get the ID of the category within the single.php page and have it display all it’s post from that category?? So then i won’t have to manually add every single number to all my post.

  27. Hi,

    I’m using the drop down post list and it stopped working recently. It’s in a password protected area of the site so I’d rather not post the password here. The category pages are appearing correctly in the drop-down menu, but the pages themselves are only returning a nonsensical excerpt with [...] at the end. Thanks for any help you can offer.

    Amanda

  28. 106
    Stew

    Hi there – GREAT Plugin.

    What I’d really like to be able to do is limit the amount of words that the list displays of every post post.
    For example I would like it to display the 1st word of each post in a category not the complete post title with “limit=1″ or something. Not sure if this can be done? But would be great.

  29. Thank’s. I’ll try…

  30. 104
    echio

    how do i get the category id, when i insert the code into my single.php file. I’m saying is it possible to have a code to get the ID of the category in the post page.

  31. 103
    Sam

    What about something like where $category is the current one that the user is browsing so that it grabs the list of posts from each specific category and not every post on every category?

    Thanks.

  32. 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!

  33. Nice plugin. Thanks for shared.

  34. Hi – does your plugin enable you to see the posts within a sub-category ? eg. Category “New Zealand” sees the sub-categories “Nth Island” & “Sth Island”.

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

  36. 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?

  37. 97
    mak sev

    trying to put this in the sidebar

    wp 3.8.4 theme atahualpa

    its not displaying

  38. 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!

  39. hey? this doesnt work!!!

    why not????

    i am using wp 2.82…..

  40. 94
    soleman

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

  41. 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?

  42. 92
    Yuna

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

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

  44. 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?

  45. 89
    Scorpio84

    i made it work after changing some php code

  46. 88
    Scorpio84

    I am using WP 2.7.1 and the latest plugin version

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

  48. 86
    Mandy

    How would I put this inside a widget?

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

  50. 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!

  51. 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!

  52. 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

  53. 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 .= ”;

    }

  54. 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.

  55. 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.

  56. 78
    Chirag

    HI

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

    pls help me to install this plugin

  57. 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.

  58. 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 :)

  59. 75
    Trish

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

  60. 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?

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

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

  63. 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?

  64. 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.

  65. 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.

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

  67. 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

  68. 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.

  69. 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

  70. Version 1.32 Released

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

  71. 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!

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

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

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

  75. 59
    Saulo Benigno

    Does it work with WP 2.7?

    Thanks.

  76. 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.

  77. 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.

  78. 56
    EgitimTUBE

    Thanks Very Good

  79. 55
    Karl

    Great plugin,

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

    Thanks

  80. Great.. works excellent for me.

  81. 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″

  82. 52
    kroma

    hmm some of my plugins caused problems … it works now

  83. 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

  84. 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! :)

  85. 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?

  86. 48
    cartmanffc

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

  87. 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

  88. 46
    Devin

    Thank a TON for the update!

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

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

  91. 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.

  92. 42
    Stout

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

  93. 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.

  94. 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/

  95. 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!

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

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

  98. 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?

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

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

  101. 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.

  102. Thanks a lot for this plugin….

  103. 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.

  104. 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

  105. 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)?

  106. 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..

  107. 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!

  108. 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.

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

  110. 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?

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

  112. 22
    reagan

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

  113. 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????

  114. 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

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

  116. 18
    Johnny

    sorry…forgot to wrap the code

    <?php echo ddpl_list(#); ?>

  117. 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?

  118. 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.

  119. 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?

  120. Karin: It is a demo, yes.

  121. 13
    Karin

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

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

  123. 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?

  124. 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.

  125. 9
    goodhand

    excellent solution, thanks so much.

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

  127. 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.

  128. 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.

  129. Version 1.3 Released

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

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

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

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

  132. 2
    gentoo7

    this is awesome, thanks a lot!

  133. 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.