Advanced Theming

HTMLy almost can list any posts based tag, category, author, or type. You just need to read the functions.php to know any get helper.

With this than we can creating our custom widget.

Get Specific Posts by Tag

We can display list of posts by tag by using built in function:

// $tag = the tag slug
// $page = the page
// $perpage = how many posts
// $random = true or false

get_tag($tag, $page, $perpage, $random)

Let say we already have Featured tag and we want displayed it as posts list.

// get the posts with featured tag
// as 1 page, 4 posts, random false

<?php $featured = get_tag('featured', 1, 4, false);?>

<?php foreach($featured as $f):?>

// the div etc. goes here.

<div class="content">
    <div class="title"><?php echo $f->title; ?></div>
    //etc....
</div>

<?php endforeach;?>

Get Specific Posts by Category

We can display list of posts by category:

// $category = the category slug
// $page = the page
// $perpage = how many posts

get_category($category, $page, $perpage)

Let say we want to display HTMLy category.

// get the posts categorized as htmly
// as 1 page, 4 posts

<?php $htmly= get_category('htmly', 1, 4);?>

<?php foreach($htmly as $h):?>

// the div etc. goes here.

<div class="content">
    <div class="title"><?php echo $h->title; ?></div>
    //etc....
</div>

<?php endforeach;?>

Other Get Helper

By Specific Keyword (Search)

get_keyword($keyword, $page, $perpage)

By Specific Type (image, video etc.)

get_type($type, $page, $perpage)

By Author

// $name = username

get_profile_posts($name, $page, $perpage)

Get Image From Post

If the content type is image by printing <?php echo $p->image; ?> will outputting the featured image. We can get an image from regular post or even video thumbnail by calling this function:

get_image($text)

If in post than it become:

get_image($p->body)