WordPress Architecture as a CMS – Posts & Pages

How can I associate posts with pages?

Trying to determine the best architecture / strategy to achieve the following…

Using WordPress as a CMS
8 Pages each with sub pages
Each page can also have posts

I can set up 8 categories where each category matches a page and then list the posts in that category under the page but that seems clunky. Is there a better way?

Awards Page
has sub page Annual Awards and
has sub page Monthly Awards
has post March 2012 Awards which should be displayed on Awards Page & Monthly Awards Page

Thanks in advance.

Solutions Collecting From Web of "WordPress Architecture as a CMS – Posts & Pages"

There is an awesome plugin by @scribu called Posts 2 Posts. It allows you to manually associate different post types (or the same post type) with each other. I use it quite a bit for bigger CMS type projects and even pluginized a common pattern I found myself writing on a few sites.

Here’s an example to do what you need with Posts 2 Posts


class WPSE45561_Pages_Posts
    private static $ins = null;

    public static function init()
        add_action('plugins_loaded', array(__CLASS__, 'instance'));

    public static function instance()
        is_null(self::$ins) && self::$ins = new self;
        return self::$ins;

    protected function __construct()
        add_action('p2p_init', array($this, 'connections'));

    public function connections()
            'name'      => 'page_to_posts',
            'from'      => 'page',
            'to'        => 'post',
            'admin_box' => array(
                'show'    => 'from', // only show on pages
                'context' => 'advanced', // put admin box in main col, instead of side

Getting connected posts on the front end is simple as well. Somewhere in the loop:

$connected = p2p_type('pages_to_posts')->get_connected($post->ID);
        // normal loop stuff here

If you don’t want to use that plugin, there are a few options.

  1. Associate a category with a given page, pull posts in from that category. You can either make this static or add a meta box to do that.
  2. Associated posts with pages via some sort of multi select (again, in a meta box).

I can provide you some example code for the above two options, but I’d strongly suggest you check out Posts 2 Posts.

If I understand you correctly, you’d need something like WP_Query to iterate through your different categories, pages, and etc. Use this:

function myAwardsPage() {

    // The Query 

    $the_query = new WP_Query( 'category_name=awards' );
    // get Params from: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
    // if multiple use array('','')

    // The Loop 
    while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <?php the_title(); ?>
    <?php the_content(); ?>

    <?php endwhile;

     // Reset Post Data

and add it to your page-template.php file then wherever you want to display that query put:

 <?php myAwardsPage(); ?>