wp_page_menu [ WordPress Function ]
wp_page_menu ( $args = array() )
| Parameters: |
|
| Defined at: |
|
Benzer Fonksiyonlar: wp_nav_menu, wp_get_nav_menus, wp_update_comment, wp_update_theme, wp_spam_comment
Display or retrieve list of pages with optional home link.
The arguments are listed below and part of the arguments are for {@link wp_list_pages()} function. Check that function for more info on those arguments.
- sort_column - How to sort the list of pages. Defaults to page title. Use column for posts table.
- menu_class - Class to use for the div ID which contains the page list. Defaults to 'menu'.
- echo - Whether to echo list or return it. Defaults to echo.
- link_before - Text before show_home argument text.
- link_after - Text after show_home argument text.
- show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link.
Source
<?php
function wp_page_menu( $args = array() ) {
$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
$args = wp_parse_args( $args, $defaults );
$args = apply_filters( 'wp_page_menu_args', $args );
$menu = '';
$list_args = $args;
// Show Home in the menu
if ( ! empty($args['show_home']) ) {
if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
$text = __('Home');
else
$text = $args['show_home'];
$class = '';
if ( is_front_page() && !is_paged() )
$class = 'class="current_page_item"';
$menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
// If the front page is a page, add it to the exclude list
if (get_option('show_on_front') == 'page') {
if ( !empty( $list_args['exclude'] ) ) {
$list_args['exclude'] .= ',';
} else {
$list_args['exclude'] = '';
}
$list_args['exclude'] .= get_option('page_on_front');
}
}
$list_args['echo'] = false;
$list_args['title_li'] = '';
$menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
if ( $menu )
$menu = '<ul>' . $menu . '</ul>';
$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
$menu = apply_filters( 'wp_page_menu', $menu, $args );
if ( $args['echo'] )
echo $menu;
else
return $menu;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- wp_page_menu - WordPress Codex
Description. Displays a list of WordPress Pages as links, and affords the opportunity to have Home added automatically to the list of Pages displayed. This Tag is ...
codex.wordpress.org - WordPress › Support » Drop Down Menu Using 'wp_page_menu'
I need a DropDown Menu for a wordpress theme which works with ' wp_page_menu'. Or at least one which works dynamically without using any plugins, i have ...
wordpress.org - wp_page_menu filter
I am trying to wrap my head around how to work with filters in general but I am hoping for some help specifically to the wp_page_menu function.
www.wptavern.com - WP First Aid | wp_page_menu
Oct 12, 2010 ... I have written several posts regarding the use of the wp_nav_menu() function. I have written about its uses, its implementation, and even an ...
wpfirstaid.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- wiegs015 on "listing pages cannot display home"
- Rev. Voodoo on "listing pages cannot display home"
- wiegs015 on "listing pages cannot display home"
- Karen Turner on "all-in-one-seo when deactivated removes wp_page_menu"
- sbjluke on "wp_page_menu custom classes"
- esmi on "wp_page_menu custom classes"
- sbjluke on "wp_page_menu custom classes"
- bhenselmann on "include costum post types in wp_page_menu()"
- equalmark on "include costum post types in wp_page_menu()"
- bhenselmann on "include costum post types in wp_page_menu()"