Need to create a Method like WordPress’s function have_posts()
for templating.
Method goes something like this:
class posts{
public function have_posts(){
$query = 'SELECT * FROM posts';
$result = mysql_query($query);
return mysql_fetch_array($result);
}
}
Using the class in the template (theme):
$posts = new posts;
while($row = $posts->have_posts()){
echo $row['post_title'];
}
But I am trying to achieve something like:
<?php while(have_posts()){ ?>
<h1><?php post_title(); ?></h1>
<?php } ?>
Alternatives & Suggestions are also welcomed 🙂
For your specific question, the following should work