Title: Show Pages and Posts
Last modified: August 21, 2016

---

# Show Pages and Posts

 *  Resolved [kezzykezyqgc](https://wordpress.org/support/users/kezzykezyqgc/)
 * (@kezzykezyqgc)
 * [12 years ago](https://wordpress.org/support/topic/show-pages-and-posts/)
 * So I love this plugin but would like to use it for both pages and posts. I’ve
   already added code to allow me to add tags and categories to my posts, but Posts
   in Page won’t pick them up, which doesn’t really surprise me.
 * I’ve been looking through the php files to see if I can find/figure out how to
   add a place to pull the information from pages instead of only posts, but I haven’t
   had much success.
 * Anyone have any ideas/suggestions?
 * [https://wordpress.org/plugins/posts-in-page/](https://wordpress.org/plugins/posts-in-page/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [kezzykezyqgc](https://wordpress.org/support/users/kezzykezyqgc/)
 * (@kezzykezyqgc)
 * [12 years ago](https://wordpress.org/support/topic/show-pages-and-posts/#post-4975711)
 * I’m thinking it has something to do with (page_posts.php):
 *     ```
       protected function paginate_links( $posts ){
       global $wp_query;
       $page_url = home_url( '/' . $wp_query->post->post_name . '/' );
       $page = isset( $_GET['page'] ) ? $_GET['page'] : 1;
       $total_pages = $posts->max_num_pages;
       $per_page = $posts->query_vars['posts_per_page'];
       $curr_page = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0	) ? $posts->query_vars['paged'] : 1;
       $prev = ( $curr_page && $curr_page > 1 ) ? '</p></p>
       <li><a href="'.$page_url.'?page='. ( $curr_page-1 ).'">Previous</a></li>
   
       <p><p>' : '';
       $next = ( $curr_page && $curr_page < $total_pages ) ? '</p></p>
       <li><a href="'.$page_url.'?page='. ( $curr_page+1 ).'">Next</a></li>
   
       <p><p>' : '';
       return '</p></p>
       <ul>' . $prev . $next . '</ul>
   
       <p><p>';
       	}
       ```
   
 * or (page_posts.php):
 *     ```
       // get posts in a certain category by name (slug)
       if ( isset( $atts['category'] ) ) {
       	$this->args['category_name'] = $atts['category'];
       } elseif (	isset( $atts['cats'] ) ) { // get posts in a certain category by id
       	$this->args['cat'] =  $atts['cats'];
       	}
       ```
   
 *  Thread Starter [kezzykezyqgc](https://wordpress.org/support/users/kezzykezyqgc/)
 * (@kezzykezyqgc)
 * [12 years ago](https://wordpress.org/support/topic/show-pages-and-posts/#post-4975756)
 * I strung together my own fix combining some code from here with that from another
   website [http://anartworkaccess.com/show-excerpt-of-child-pages-on-a-parent-page-with-a-shortcode/](http://anartworkaccess.com/show-excerpt-of-child-pages-on-a-parent-page-with-a-shortcode/)
 * So I put
 *     ```
       function subpage_peek() {
       global $post;
       //query subpages
       $args = array(
       'post_parent' => $post->ID,
       'post_type' => 'page'
       );
       $subpages = new WP_query($args);
       // create output
       if ($subpages->have_posts()) :
       $output = '<ul>';
       while ($subpages->have_posts()) : $subpages->the_post();
       $output .= '<h2><a href="'.get_permalink().'">'.get_the_title().'</a></h2>
       <a href="'.get_permalink().'">
       <p>'.get_the_post_thumbnail( $postid,  array(180,9999), array('class' => 'alignleft') ).'</a>'.get_the_excerpt().'<br />
       </p>';
       endwhile;
       $output .= '</ul>';
       else :
       $output = '<p>No subpages found.</p>';
       endif;
       // reset the query
       wp_reset_postdata();
       // return something
       return $output;
       }
       add_shortcode('subpage_peek', 'subpage_peek');
       ```
   
 * into the functions.php file, which let’s you post subpages on parent pages using
   the shortcode [subpage_peek}. I added the ability to show the featured image 
   at the same size one of the posts for displaying the featured image as a post
   in page so you can go back and forth between them without losing formatting and
   I made sure the image links to the page. It doesn’t worth for categories or tags,
   but it works for what I needed at the moment. If anyone can figure out how to
   do it for tags/categories, please post here. Thanks!
 *  Plugin Contributor [Patrick Jackson](https://wordpress.org/support/users/pjackson1972/)
 * (@pjackson1972)
 * [12 years ago](https://wordpress.org/support/topic/show-pages-and-posts/#post-4976009)
 * Hi kezzykezyqgc,,
 * One way you can get pages to be listed is to set the **post_type** attribute 
   to **“page”** in the shortcode.
 * For example a shortcode that reads…
 * **[ic_add_posts post_type=’page’ ]**
 * … would list all of the content for all pages on the site.
 * Now, this would include the page with the Posts in Page shortcode, so you may
   want to limit your list.
 * One way to do this would be to include the Page (or Post) ids of the pages you
   want to list. To get the page id, go to edit the page you want to add, and look
   at the URL, which may look something like…
 * [http://www.example.com/wp-admin/post.php](http://www.example.com/wp-admin/post.php)?**
   post=2**&action=edit
 * Where it says **post=2** tells you that this page’s post id is 2.
 * If I create a shortcode that says…
 * **[ic_add_posts post_type=’page’ ids=’2′]**
 * … then the _posts in page_ list will include the page with id=2. You can list
   multiple pages by separating the ids with commas:
 * **[ic_add_posts post_type=’page’ ids=’2,4,23′]**
 * The above would only show pages. Now suppose you want to list both pages and 
   posts in your list. In the above example, if 23 were a Post instead of a Page,
   it would not show in the resulting list because we specified only the _Page_ 
   post_type.
 * Now, you can also add a comma to your post_type attribute. The following would
   list all pages _and_ posts.
 * **[ic_add_posts post_type=’page, post’]**
 * The following would list the items with the given ids whether they’re posts or
   pages:
 * **[ic_add_posts post_type=’page,post’ ids=’2,4,24,53,101′]**

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Show Pages and Posts’ is closed to new replies.

 * ![](https://ps.w.org/posts-in-page/assets/icon-256x256.png?rev=1596190)
 * [Posts in Page](https://wordpress.org/plugins/posts-in-page/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-in-page/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-in-page/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-in-page/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-in-page/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-in-page/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Patrick Jackson](https://wordpress.org/support/users/pjackson1972/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/show-pages-and-posts/#post-4976009)
 * Status: resolved