Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am looking to add blog details to the following dropdown list to replace the option value $site['domain'] with the detail blogname while keeping $site[domain] as the option content.

XML
function blavou_existing_sites() {
    echo '<div id="blav-wrapper">';
    echo '<div class="blav-nav-wrapper">';
    echo '<ul class="blav-drop">';
    echo '<form action="../">';
    echo '<select name="mySelectbox" id="mySelectbox">';
    echo '<option value="">Choose Existing</option>';
    $sites = wp_get_sites();
    foreach ($sites as $site) {
        printf( '<option value="http://'.$site['domain'].'/wp-admin/">'.$site['domain'].'</option>');
    }
    echo '</select>';
    echo '<input type="button" onclick="window.open(this.form.mySelectbox.options[this.form.mySelectbox.selectedIndex].value,\'_top\')" value="Confirm">';
    echo '</form>';
    echo '</ul>';
    echo '</div>';
    echo '</div>';
}


Help Appreciated!
Posted
Comments
ZurdoDev 26-Feb-15 22:17pm    
Where are you stuck? What is your question?

1 solution

PHP
foreach ($sites as $site) {
    $details = get_blog_details($site['blog_id']);
    printf( '<option value="%s">%s (%s)</option>', 'http://'.$site['domain'].'/wp-admin/', $details->blogname, $site['domain'] );
 }


Thanks to bobdye - winecountrywebdesign.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900