2015-11-02 73 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; 

}