Support » Themes and Templates » Changing the loop to display the list of written pages.

Changing the loop to display the list of written pages.

  • I think I understand that you can’t just create a page of custom name and then just hook it into the template hierarchy. So if I can’t do that then I need to change the loop in index.php to be able to distinguish between a link that was clicked.

    Instead of displaying a list of our pages in one of the sidebars … I would like to have a pages button (which I got) that when clicked will display the list of our written pages. So my understanding is that I need to modify the loop somehow so that I can distinguish between when the pages button is clicked and then call <?php wp_list_pages(‘title_li=<h2>Pages</h2>’); ?> or something to that effect … Does anyone know how I could do this?

    Is this possible … or are there any functions that I can make use of? Or even plugins that anyone knows about?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Your first sentence is not entirely correct. You can create custom Page templates with whatever name you like and put them into the theme folder. In those template files you can use any template tags you like – including wp_list_pages.
    You can actually have a Page template that has in the content area ONLY the template tag above (no Loop, no nothing 🙂 and it will display the list of your Pages. From your index/sidebar you can have a simple link to the Page created by using this template.
    Why do you need a plugin for this?

    Oh … thanks for clearing that up … In that case I can’t seem to find sufficient documentation to help me create such a page … Do you know where I could find some help on this matter … or maybe do you have any suggestions on how I should go about creating this custom page?


    Just for the sake of clarity (which means more chance that we understand each other 😉 –
    first you create a Page template
    then you create a Page in the admin panel Write > Write Page by using that template.
    Start here: Pages#Page_Templates

    I think I see now … I was trying to create it purely programatically … But you esentially create a page through wordpress (the cms part), which in my case was completely blank to start, and then specify what template (which I create) that page uses, by again using wordpress (the cms part).

    Thanks for the help! With any luck I got it …

    Basically – yes. In the Write > Write Page panel if you have only the default Page template file in the theme (page.php) you will not see it, but as sson as you have more Page templates uploaded – there will be a dropdown menu for Page Template in the Page Options below the text input area.
    Just follow the order I suggested: make a template (or two, or 3 or 6 🙂 and then go to write a Page.
    In the special case of Archives or Links and probably of this “pagelisting”, too, you don’t have to write anything in the Write panel, just give it a title and click Create new Page.

    I managed to get that custom page up and running but now I am attempting a second custom page and its not working …

    I have created a blank template page with the template name at the top of that page commented out … and then I have gone to write a page and selected the appropriate template but I want this page to have content Eg: there is going to be a list of contributors and paragraphs about them here. But I am not sure if I should be putting the content in the content box when creating the page in wordpress and then if that’s the case I am not sure how to display the content or link to that content on that page?


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Changing the loop to display the list of written pages.’ is closed to new replies.