• Resolved lloydchrein

    (@lloydchrein)


    We have a dropdown placed here: https://motherearthproject.org/hall-of-achievements/

    We need to add new countries on a regular basis. But the plugin only allows us to add new items at the bottom, so that if we add, say, Algeria now, it will appear at the bottom. To make it appear at the top, we need to move each country down one slot – and this will get to be a real problem when we have (anticipated) over 100 in the list.

    Is there perhaps (or can you add) a shortcode tag we can use to display the items in alphabetical order on the front end – regardless of the order seen in the admin screen? Or can you tweak this so that we can drag/drop new items into the desired order in the admin?

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter lloydchrein

    (@lloydchrein)

    Hi – I’m hoping you will have a chance to address this question soon. I got a reply from another thread, but that was just to reverse the order of the items in the pulldown.

    I am trying to manually control the order, by hopefully either dragging and dropping items (taxonomy control) in the admin, or at least being able to add new items for the pulldown into a specific spot/order in the list.

    Thank you!

    Plugin Author alordiel

    (@alordiel)

    Hello,
    To fix this you will need to edit a php file.
    Hope you have FTP access. Log-in and find the named : dropdown-multisite-selector.php. It should be located in : wp-content/plugins/dropdown-multisite-selector/dropdown-multisite-selector.php.

    Once you have opened the php file find function called function noneOptions(). In it you will find some rows like:

    if ( $options ) {
      foreach ( $options as $key => $value ) {
    	$out .= "<option value='" . $value . "'>" . $key . "</option>";
      }
    }

    Then you need to add this one line of code between the if and the foreach:

    $options = ksort($options);

    So your new code should look like:

    if ( $options ) {
      $options = ksort($options);
      foreach ( $options as $key => $value ) {
    	$out .= "<option value='" . $value . "'>" . $key . "</option>";
      }
    }

    Then save the file and upload it back to your ftp from where you have opened it.

    Then everything should work.

    Please let me know if any issues and sorry for the late response.

    Regards,
    Al

    Thread Starter lloydchrein

    (@lloydchrein)

    Hi – I implemented this as noted. See code below. It didn’t seem to allow sorting/ordering of the items on the admin screen, and the pulldown stopped working on the front end. So I deleted the new line. Please advise!

    This is how the code looked after I pasted the line as instructed above:

    function noneOptions(){
    $out = “”;
    $options_db_select = ‘dms_options’;

    if ( get_option( $options_db_select ) ) {
    $options = get_option( $options_db_select );
    }

    if ( $options ) {
    $options = ksort($options);
    foreach ( $options as $key => $value ) {
    $out .= “<option value='” . $value . “‘>” . $key . “</option>”;
    }
    }
    else{
    $err = “<p class=’error-front’>” . __(“Missing data. Check if all the settigns are correctly set in your admin area regarding ‘Dropdown Multisite selector'”,’dropdown-multisite-selector’) . “</p>”;
    return $err;
    die();
    }

    return $out;
    }

    Plugin Author alordiel

    (@alordiel)

    Hi,

    I have just push a new version to the WordPress Plugin’s repository which includes this function so you(and everybody else) don’t have to touch any code. The new version is already in the repo and you can update. No need to edit any code.

    Just for the record:
    It was my mistake. Instead of:

    $options = ksort($options);

    It should be:

    ksort($options);

    Regards,
    Al

    • This reply was modified 8 years, 2 months ago by alordiel.
    • This reply was modified 8 years, 2 months ago by alordiel.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Alphabetical Order of Items in Dropdown’ is closed to new replies.