I'm new to WordPress so please bear with me. I have a requirement where I need to create a page that contains a lot of static and dynamic content coming from the db. What is the best approach to do this:

  1. have 'n' shortcodes for 'n' dynamic regions?
  2. have only one shortcode that builds the entire page?
  3. any other solution?
  • Could you provide us with some more details? This is not enough info to me. Every site has dynamic and static content.
    – RTB
    Commented Aug 3, 2012 at 22:43
  • I want to create the page using Wordpress HTML editor. I can easily add static content but how to add the dynamic contents that is coming from the db? I hope you got my question now?
    – Pooja
    Commented Aug 4, 2012 at 14:09

1 Answer 1


Using WP's templates you can create a page with static content already in it, and just grab the dynamic parts using WP_Query class.

<h1>Static Header</h1>
<div id="dynamic_content1">
$recentPosts = new WP_Query();
while ($recentPosts->have_posts()) : $recentPosts->the_post();
    the_content();  // Put Loop Stuff Here
<div id="other_dynamic_content">
    $anotherQuery = new WP_Query();
     while ($anotherQuery->have_posts()) : $anotherQuery->the_post();
        the_content();  // Put Loop Stuff Here
     endwhile; ?>

As you can see from the example you can load multiple dynamic components into a single page.

WordPress's template schema works as follows {post-type}-{slug/id}.php

So a page with a title of about would be page-about.php. Wordpress will automatically look for that page first when you go to /about/ if it's not in your them folder it falls back to the page.php file, if it doesn't exist it falls back to index.php (which must exist for your theme to work).

Also for posts you can follow the same schema single-{post-type}.php etc. Check out the WP template Hierarchy and WP_Query class in the codex for more info, such as the query paramaters.

  • Thanks bgallagh3r. I have implemented your solution for the dynamic content!
    – Pooja
    Commented Aug 6, 2012 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.