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

Pages: « 9 8 7 [6] 5 4 3 2 1 » Show All

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

  2. 89
    Scorpio84

    i made it work after changing some php code

  3. 88
    Scorpio84

    I am using WP 2.7.1 and the latest plugin version

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

  5. 86
    Mandy

    How would I put this inside a widget?

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

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

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

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

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

    }

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

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

  13. 78
    Chirag

    HI

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

    pls help me to install this plugin

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

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

Pages: « 9 8 7 [6] 5 4 3 2 1 » Show All

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.