PHP Learning Note (iv), PHP learning Note _php Tutorial

Source: Internet
Author: User

PHP Learning Notes (iv), PHP learning notes


Some functions in the Wordpress framework:

Wp_get_nav_menu ($default): gets the menu according to the condition $default, by default gets all the menu

where $default default is as follows:

$default Array (  = = ',  ' menu ' = = ', '  container ' = ' div ',  ' container_class ' = ' menu-{menu_ ') Slug}-container ',  ' container_id ' = ' and ',  ' menu_class ' = ' menu ',  true,  ' fallback _CB ' + ' wp_page_menu ', ' before ' + ', ' after  ' = ', '  link_before ' =  ', ' link_ After ' = = ',  ' items_wrap ' + '
 
  
  
    %3 $s
, ' depth ' =>0, ' Walker ' = ');

Description of the parameter:

$theme _location: Default is None, specifies that one of the navigation menus is registered, and if not specified, the first one is displayed. such as primary, secondary, etc.

$menu: The default is None, use the name of the navigation menu to invoke the menu, you can make term_id, slug, name and other properties

$container: The default is Div, is the parent node of UL, only support Div and nav tag, also can use false to remove the label of the UL parent node

$container _class: Default is Menu-{menu_slug}-container, which is the class property of the UL parent node

$container _id: Default is None, the ID of the UL parent node

$menu _class: The default is menu, the Class property of the UL node

$menu _id: Default is menu slug, self-growing UL Node id attribute value

$echo: The default is true to determine the direct display of the navigation menu Korean return HTML fragment, if you want to use the navigation code as a skin, you can set to false.

$fallback _db: The default value is Wp_page_menu for callback functions that do not have a navigation Si cho set in the background

$items _wrap: Default is None, use string modification to replace UL class

$depth: Defaults to 0, displays the menu's level depth, and displays a menu of all depths for 0 o'clock

$walker: The default is to use new Walker_nav_menu (), a custom traversal object, to invoke a Walker subclass object definition to display the navigation menu.

Use the Walker subclass to create a custom menu:

The Walker class is an abstract class that defines how navigation is displayed, including 4 properties and 6 methods:

Property:

$tree _type, $db _fields, $max _pages, $has _children

Method:

START_LVL: This method is executed when the Walker class reaches the top of the structure and can be used to output the start element

END_LVL: Turn off element labels for START_LVL output

Start_el: Output a start tag for each element

End_el: Turn off the Start_el label

(CORE) Display_element: Defines how to display elements in a tree structure

(core) walk each element in a circular tree structure, based on the $max_depth

If you need custom navigation, you can simply write a class class to inherit Walker, but this overrides all methods. If the changes are not significant, you can directly inherit the Walker_nav_menu class, overriding the classes that need to be modified.

When overriding Display_element, the parameter $element contains all the information for the element that is currently traversed, such as the term_id of the current element can be obtained with $element->object_id

Code snippet: Use Add_shorcode (' name ', ' function_name ') to generate a code snippet [' name '] in the system, which can be used directly in WordPress background articles, or in code Show_shortcode [' [name] ']; Direct execution

http://www.bkjia.com/PHPjc/1101865.html www.bkjia.com true http://www.bkjia.com/PHPjc/1101865.html techarticle PHP Learning Note (iv), PHP learning Note Some of the functions in the Wordpress framework: Wp_get_nav_menu ($default): According to the conditions $default get menu, the default gets all the menu which $d ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.