Binders: related

TODO

 

/**
 * Retrive a list of related posts. This binder requires the 
 * BAW Manual Related Posts plugin to be instaled in the blog.
 *
 * @param {object} $params
 * 				$params['post_id'] (optional, uses current post ID if nor post_id is provided)
 * 				$params['assign_to'] (optional, uses "related" as the name of the variable to which data is assigned).
 *
 * @example
 *
 * {{related post_id="23" assign_to="rel_posts"}}
 * 
 * <ul>
 * 	{{foreach $rel_posts.data as $item}}
 * 		<li>{{$item.post_title}}</li>
 * 	{{foreachelse}}
 * 		<p>No related posts.</p>
 * 	{{/foreach}}
 * </ul>
 *
 * @see https://wordpress.org/plugins/baw-manual-related-posts/
 *
 */

 

Example:

<ul class="appc-dynamic" id="appc-related">      
{{related post_id="{{$post.ID}}" assign_to="rel_posts"}}
{{foreach $rel_posts.data as $item}}
    <li>
        <div class="popular-post-img">
            <a href="{{$item.post_permalink}}"> <img src="{{$item.post_thumbnail}}" alt="{{$item.post_title}}"></a>
        </div>
        <div class="popular-post-content">
            {{post show="categories" assign_to="item_categories" post_id="{{$item.ID}}"}}
            <div class="post-category">
                
                {{if $item_categories.data[0]}} 
                <a href="{{$item_categories.data[0].cat_permalink}}" class="cat-item-{{$item_categories.data[0].cat_ID}}" rel="category tag" title="{{$cat.name}}">{{$item_categories.data[0].name}}</a>
                {{/if}}
            </div>
            <h4><a href="{{$item.post_permalink}}" rel="category tag">{{$item.post_title}}</a></h4>
            <span>{{date when="{{$post.post_date}}" format="F j, Y"}}</span>
        </div>
    </li>
{{foreachelse}}
 	<p>No related posts.</p>
{{/foreach}}
</ul>

 

Leave a Reply

Your email address will not be published. Required fields are marked *