Including a Miniloop using Template Tags
-
I am looking to create a mini-loop as part of a mostly Static page. However, for the purposes of CMS I want the rest of the page (mostly a welcome message) to be something that can be edited by another user.
If I were to create a page called “Welcome Message” and in the page.php Template added this code:
<?php if(is_page('Welcome Message')) { $how_many=5; //How many posts do you want to show require_once('wp-config.php'); // Change this for your path to wp-config.php file ?> <ol id="whats-new"> <? $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); foreach($news as $np){ printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title); } }?>
Do you think that would do what I wanted?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Including a Miniloop using Template Tags’ is closed to new replies.