2015-11-02 74 views
-1

更改Wordpress导航订单,而不使用菜单或页面顺序。更改Wordpress导航订单

我希望主页成为标准的首页en联系页面是最后一页。这可能没有使用WordPress的菜单或页面顺序?

+2

是的,这是可能的CSS或JS。你目前的页面代码是怎样的?你可以发布代码或链接到页面? –

+0

我通过使用wp_list_pages构建自己的导航函数来解决此问题。 – Kris

+0

很高兴你解决了它。您可以发布解决方案,以便其他人可以从中受益吗? –

回答

0

与wp_list_pages解决它:

功能build_navigation_menu(){

// Get contact page by title 
$contact_page = get_page_by_title('Contact'); 

// If exists get ID 
if ($contact_page) { 

    $contact_id = $contact_page->ID; 
} 


// Get home page by title 
$home_page = get_page_by_title('Home'); 

// If exists get ID and fetch home page link 
if ($home_page) { 

    $home_id = $home_page->ID; 

    $args = array(
     'include'  => $home_id, 
     'title_li'  => '', 
     'depth'   => 2 
    ); 

    $home_page = wp_list_pages($args); 
} 

// Get all links except contact and home 
$args = array(
    'exclude'  => $contact_id . ',' . $home_id, 
    'title_li'  => '', 
    'depth'   => 2, 
    'walker' => new pdc_walker()  
); 

$pages = wp_list_pages($args); 

// If contact page exists fetch link 
if ($contact_page) { 

    // Add call me now link 
    $call_now = '<li class="call-now"><a href="#">Call now</a></li>'; 

    $args = array(
     'include'  => $contact_id, 
     'title_li'  => '', 
     'depth'   => 2   
    ); 

    $contact_page = wp_list_pages($args); 
} 

$navigation_pages = $home_page . $pages . $contact_page . $call_now; 

return $navigation_pages; 

}