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

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745187279a4615696.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信