Return content from static wordpress pages

I’m currently coding my own WordPress Theme and I would like to have a (static) page that lists all the titles of the other static pages.
By static page I mean the “page” in WordPress. As you know, you can publish content on pages or on posts.

The reason is, that I want to publish the main articles on a static page and only have our blog in the post section of the WordPress dashboard. The end-user should be able to reach a page by the navigation which display a listing of the pages that are available. As there are several people that write and publish on our site, it would be very useful if we could automate the output of the content.

Read More

Thank you very much in advance!

Related posts

1 comment

  1. Well…I think you should take a look at WordPress Codex.They have pretty much everything in there..!

    Here is the link to get all static pages :

    https://codex.wordpress.org/Function_Reference/get_pages

    Here Is Ready Code For You!!!!

    Displaying pages in dropdown list:

    In this example a dropdown list with all the pages. Note how you can grab the link for the page with a simple call to the function get_page_link passing the ID of the page.

    <select name="page-dropdown"
     onchange='document.location.href=this.options[this.selectedIndex].value;'> 
     <option value="">
    <?php echo esc_attr( __( 'Select page' ) ); ?></option> 
     <?php 
      $pages = get_pages(); 
      foreach ( $pages as $page ) {
        $option = '<option value="' . get_page_link( $page->ID ) . '">';
        $option .= $page->post_title;
        $option .= '</option>';
        echo $option;
      }
     ?>
    </select>
    

Comments are closed.