ME again, but this is more of a query then something I'm stuck with.
When developing a WordPress theme, each part of the post is a different function, EG:
- Code: Select all
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<h4 class="date"><?php the_time('M jS') ?></h4>
My function currently just gets it all:
- PHP: Select all
function display_posts() {
global $postnumber;
$display_posts_home = mysql_query("SELECT contentid, contenttitle, contentintro, content, author, category, homepage, date_format(date, '%M %D, %Y') AS date FROM content WHERE homepage='Y' ORDER BY contentid DESC LIMIT 0 ,$postnumber");
if(!$display_posts_home) {
echo '<h4>Error Displaying Content.' . mysql_error() . '</h4>';
}
while ($posts = mysql_fetch_array($display_posts_home)) {
$contentid = $posts['contentid'];
$contenttitle = $posts['contenttitle'];
$contentintro = $posts['contentintro'];
$content = $posts['content'];
$author = $posts['author'];
$category = $posts['category'];
$date = $posts['date'];
$comments_number = mysql_query("SELECT count(commentsid) FROM comments WHERE commentsid = '$contentid'") or die(mysql_error());
$results = mysql_result($comments_number, "0");
//display
echo '<div class="post">';
echo '<h4 class="homepageposttitle"><a href="single.php?contentid=' . $contentid . '">' . $contenttitle . '</a></h4>';
echo '<h5 class="homepagepostinfo"><span class="postid">#' . $contentid . ' |</span> By <span class="postauthor">' . $author . ' </span> On: <span class="postdate">' . $date . '</span></h5>';
echo '<p class="homepagepostintro">' . $contentintro . '</p>';
if ($results==1) {
echo '<p class="homepagepostcomments">There has been ' . $results . ' Comment</p>';
} else {
echo '<p class="homepagepostcomments">There have been ' . $results . ' Comments</p>';
}
echo '<a href="single.php?contentid=' . $contentid . '">Continue Reading "' . $contenttitle . '"</a></div>';
}
}
And that is fine for me, but for people who want to customize the way their posts are displayed, they cannot. How can I emulate the way WordPress looks, and have a function for finding each seperate part of each post?