WordPress.org

Forums

PROBLEM: rearranging pages (9 posts)

  1. littlecuriosity
    Member
    Posted 5 years ago #

    Hi
    I have a theme I'm trying to edit. Frustratingly every time I publish a new page something in the code won't let me rearrange the order of the pages after I've published them. I've even tried using page order plugins which seem to work in the admin but not on the live view.

    This is the code I'm talking about, at the end you'll notice 'order by ID', even if i delete this it has no effect so what can I put instead that enables me to rearrange pages. This theme does not include wp_pages_list!

    $pages = $wpdb->get_results("SELECT post_name, post_title, ID FROM $wpdb->posts WHERE post_type='page'and ID < 303" order by ID);

    Thanks
    Judi

  2. littlecuriosity
    Member
    Posted 5 years ago #

    note: i am trying to include a certain number of pages in the top navigation. the last few published by function dissappear so I can put them in a sidebar with a widget.

  3. MichaelH
    Member
    Posted 5 years ago #

    You don't say "what order" you want to use, but changing the "order by ID" to "order by post_title" would change the order to alphabetic order. You could use "order by menu_order" if you wanted to use the value from the Order field (in Edit/Add Page) to determine the order.

    The "ID < 303" means you are excluding any post ID higher that 302.

  4. littlecuriosity
    Member
    Posted 5 years ago #

    thanks michael,
    If i use menu_order is there a way to exclude certain pages from the nav instead of using < 303 or do I just delete this value and put menu_order?

  5. littlecuriosity
    Member
    Posted 5 years ago #

    As if i delete this value all the pages will appear in my top nav which I want to avoid.

  6. littlecuriosity
    Member
    Posted 5 years ago #

    Please help me im a bit of a novice and don't understand how to configure the code. The nav dissappears completely when I put

    WHERE post_type='page'and ID < 303" order by menu_order);
    or
    WHERE post_type='page'and ID < menu_order);
    or
    WHERE post_type='page'and menu_order);

  7. littlecuriosity
    Member
    Posted 5 years ago #

    I want 6 pages I choose appear in the nav

  8. MichaelH
    Member
    Posted 5 years ago #

    $pages = $wpdb->get_results("SELECT post_name, post_title, ID FROM $wpdb->posts WHERE (post_type='page' and post_status='publish' AND ID in (123,165,114)) ORDER BY menu_order");

  9. littlecuriosity
    Member
    Posted 5 years ago #

    Thanks so much it works like a dream!

Topic Closed

This topic has been closed to new replies.

About this Topic