WordPress.org

Ready to get started?Download WordPress

Forums

How to get a second page widget? (10 posts)

  1. LanceGrigsby
    Member
    Posted 6 years ago #

    I'm retooling the default Kubrick that ships with WordPress, and I've been able to install an additional sidebar. I want to install a third "sidebar" for a top nav bar that has unique page navigation. Trouble is, I need an additional "Pages" widget to make this happen. I've located the code for the widgets in wp-includes/widgets.php, but am unsure how to make this happen. Do I need to look into creating a dropdown menu like Categories/Text/RSS widgets, or simply find a way to duplicate the widget itself? Any help would be appreciated.

  2. MichaelH
    Member
    Posted 6 years ago #

    Why not resort to just using the template tag, wp_list_pages(), where you want to display that navigation?

  3. LanceGrigsby
    Member
    Posted 6 years ago #

    Hello Michael. Well, I did that at first, and it works fine. However, with top navigation, too many pages means an unattractive top nav bar because your list items just begin a new line below where they should be if you get too many. With the page widget, you can exclude certain pages from showing up, and that solves that problem. But what if you had two page widgets--one for top nav and one for the sidebar, and you could exclude certain pages from both to 1). avoid the aforementioned scenario with the top nav and 2). have a unique listing of pages in both areas so the same page link doesn't show up twice. For example, check out npr.org. Unique list of pages in the top nav, and a unique list of pages in the sidebar. Way I figure it, only way to accomplish this is to have two page widgets if you also want to preserve blogging capabilities and not use categories as pseudo-page links.

  4. MichaelH
    Member
    Posted 6 years ago #

    Well the widget just uses the wp_list_pages() with the exclude= parameter.

  5. LanceGrigsby
    Member
    Posted 6 years ago #

    OK, thanks. However, I should have written earlier that my real intention for doing this is to make it easy for a person on the backend to make changes to page listings in the topnav/sidebar using the Dashboard interface rather than making it necessary to modify the code. Again, having 2 configurable page widgets that can be dragged to both locations would be ideal. Is there no way to generate a dropdown menu on the widgets page that allows you to specify the number of page widgets you want?

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Is there no way to generate a dropdown menu on the widgets page that allows you to specify the number of page widgets you want?

    No easy way, no. You would have to rewrite the page widget to allow multiple instances of it.

  7. LanceGrigsby
    Member
    Posted 6 years ago #

    That's what I figured. Thanks ...

  8. LanceGrigsby
    Member
    Posted 6 years ago #

    How is that parameter associated with that wp_list_pages() function if I go that route? What does that coding look like using the exclude=?

  9. moshu
    Member
    Posted 6 years ago #

    Just read the documentation that MichaelH linked to earlier:
    Template_Tags/wp_list_pages

  10. LanceGrigsby
    Member
    Posted 6 years ago #

    Perfect, thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic