• Resolved sergiogill

    (@sergiogill)


    Can anyone explain what is happening here:

    wp_nav_menu( ‘sort_column=menu_order&menu_location=main-menu&container_id=nav&menu_class=sf-menu’ )

    When I try to find info online, all I get is how to work with very clean and organized arrays:

    https://codex.www.ads-software.com/Function_Reference/wp_nav_menu

    … to be more specific, what is this: “sort_column=menu_order&menu_location=main-menu&container_id=nav&menu_class=sf-menu”

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • It’s just another way of coding the attributes for wp_nav_menu. You could equally write it as:

    $args ' => ' array(
    	'sort_column' => 'menu_order',
    	'menu_location' => 'main-menu',
    	'container_id' => 'nav',
    	'menu_class' => 'sf-menu'
    );
    wp_nav_menu( $args );

    Is that more like the examples you’ve seen?

    Thread Starter sergiogill

    (@sergiogill)

    Thank you for your prompt response but can you extend further? I can easily understand your example but I want to understand what is happening here as well: “sort_column=menu_order&menu_location=main-menu&container_id…”

    I can’t seem to find the relationship! what is “=” and what is “&” doing in this case?

    If you have a link to a tutorial, i would pretty much appreciate it.

    Key value pairs: https://en.wikipedia.org/wiki/Attribute-value_pair
    Query String: https://en.wikipedia.org/wiki/Query_string
    Associative arrays: https://en.wikipedia.org/wiki/Associative_array

    “sort_column=menu_order&menu_location=main-menu&container_id…” is a query string part with a series of key value pairs
    Esmi’s PHP array is the same set of key value pairs in an associative array

    Thread Starter sergiogill

    (@sergiogill)

    Thank you tcbarrett!!!

    So this is a query string!

    field1=value1&field2=value2&field3=value3…

    “The series of pairs is separated by the ampersand, ‘&’ or semicolon, ‘;’.” from wiki

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_nav_menu SHORTHAND? SYNTAX?’ is closed to new replies.