wordpress - How to make navigation a <select> list without a plugin? -


i have tried several solution this, none of them worked.
managed make nav list <select><option> list, without names of pages, without indication of url

any ideas how can make functional select list navigation without external plugin?

(the ideal solution pages urls appear value in option can use javascript page navigation)

if don't have custom script loader, add theme's functions.php:

function addscripts() {      if ( !is_admin() ) {           wp_register_script('navscript', get_template_directory_uri() . "/js/navscript.js"));           wp_enqueue_script('navscript');  } }  add_action( 'wp_print_scripts', 'addscripts'); 

in wordpress dashboard, go appearance->my custom widgets, create new widget (give name, select html type), , add version of (leaving out div, can contain/style liking):

<form>      <select id="supernav">         <option value="">choose destination...</option>         <option value="http://www.yahoo.com/">yahoo</option>         <option value="http://www.google.com/">google</option>         <option value="http://www.amazon.com/">amazon</option>     </select>  </form> 

then, under appearance->widgets, add new custom widget wherever you'd go.

in navscript.js (in appropriate template js directory, indicated above), can add code code follows. i'm doing jquery, it's reworked plain javascript using addeventlistener():

$(document).ready(function() {      $('#supernav').change(function() {          var cururl = $("option:selected", this).val();          if (cururl) {              window.open(cururl, '_top')          }      }); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -