最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

menus - How can I order these pages in this navigation bar on this old wordpress theme?

programmeradmin1浏览0评论

It's using a superceded theme with no support. Even so, the theme has been working great for about a decade...

Here is the site:

There is no menu to organise in the appearance settings. This theme orders them alphabetically using this code (I think)

    function greenday_get_menu_from_pages() {

    $pages = & get_pages($args);
    if ( $pages ) {

        foreach ($pages as $page) {
            $output = '<li><a href="' . get_page_link($page->ID) . '">' . $page->post_title . '</a></li>';
            echo $output;
        }
    }

}

&

<?php    greenday_get_menu_from_pages();    ?>

I have specified the page ordering with numbers in the page attributes; there is no effect. I have tried several "page ordering" plugins but they all fail to do the job.

I vaguely remember I was using html spaces to organise the pages ages back, that's not a great workaround anymore as there are too many items in the navigation menu.

&nbsp; 

The pages appear in the correct order in the wordpress admin...

This is my preferred order:

  • About Design Products Reviews Gallery Philosophy FAQ News Contact

I am not a programmer so it is beyond my capabilities to code from scratch although I can copy/paste/edit if someone has a workaround... :-/

It's using a superceded theme with no support. Even so, the theme has been working great for about a decade...

Here is the site: https://www.vertebr.ae

There is no menu to organise in the appearance settings. This theme orders them alphabetically using this code (I think)

    function greenday_get_menu_from_pages() {

    $pages = & get_pages($args);
    if ( $pages ) {

        foreach ($pages as $page) {
            $output = '<li><a href="' . get_page_link($page->ID) . '">' . $page->post_title . '</a></li>';
            echo $output;
        }
    }

}

&

<?php    greenday_get_menu_from_pages();    ?>

I have specified the page ordering with numbers in the page attributes; there is no effect. I have tried several "page ordering" plugins but they all fail to do the job.

I vaguely remember I was using html spaces to organise the pages ages back, that's not a great workaround anymore as there are too many items in the navigation menu.

&nbsp; 

The pages appear in the correct order in the wordpress admin...

This is my preferred order:

  • About Design Products Reviews Gallery Philosophy FAQ News Contact

I am not a programmer so it is beyond my capabilities to code from scratch although I can copy/paste/edit if someone has a workaround... :-/

Share Improve this question edited Sep 4, 2019 at 4:34 Doc Brown asked Sep 4, 2019 at 4:26 Doc BrownDoc Brown 111 silver badge3 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I suggest you change code of your greenday_get_menu_from_pages() function a little bit, just so that the results are not ordered by post_title which is default for get_pages(), but ordered by menu_order, which is what most "page ordering" plugins you have tested actually work with.

So here is one new line in your function:

function greenday_get_menu_from_pages() {

    $args = array('sort_column' => 'menu_order');

    $pages = get_pages($args);
    if ( $pages ) {

        foreach ($pages as $page) {
            $output = '<li><a href="' . get_page_link($page->ID) . '">' . $page->post_title . '</a></li>';
            echo $output;
        }
    }

}

And then, you can install plugin such as Intuitive Custom Post Order, go to Settings > Intuitive CPO - set it up to be available for Pages as you can see on this screen:

And then, go to your Pages tab and simply drag and drop the entries there.

Side note: i've also removed the ampersand & for reference before your get_pages() call, not sure if that was any important, seemed rather obsolete to me.

发布评论

评论列表(0)

  1. 暂无评论