-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·36 lines (28 loc) · 915 Bytes
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
function register_my_menu(){
register_nav_menu('header-top',__('Header Navigation'));
}
add_action('init', 'register_my_menu');
function new_nav_menu_items($items)
{
$items = "";
$args = array("post_type" => "page", "order" => "ASC", "orderby" => "menu_order");
$the_query = new WP_Query($args);
if($the_query->have_posts()):
while($the_query->have_posts()):
$the_query->the_post();
$items .= '<li><a href="#'. the_slug() .'">' . get_the_title() . '</a></li>';
endwhile;
else:
echo "";
endif;
return $items;
}
add_filter("wp_nav_menu_items", "new_nav_menu_items");
function the_slug($echo=true){
$slug = basename(get_permalink());
//do_action('before_slug', $slug);
$slug = apply_filters('slug_filter', $slug);
//do_action('after_slug', $slug);
return $slug;
}