Skip to content

Instantly share code, notes, and snippets.

@ajtatum
Created Jan 28, 2022
Embed
What would you like to do?
MetaBox Recent Posts
{% set args = { post_type: 'post', posts_per_page: 4 } %}
{% set posts = mb.get_posts(args) %}
{% for post in posts %}
{% set post_url = mb.get_the_permalink(post.ID) %}
{% set thumbnail_id = mb.get_post_thumbnail_id(post.ID) %}
{% set featured_image_url = mb.get_the_post_thumbnail_url(post.ID, 'ajt-medium-wide') %}
{% set featured_image_srcset = mb.wp_get_attachment_image_srcset(thumbnail_id) %}
<div class="ajtd-recent-posts">
<div class="ajtd-rp-inner-section">
<div class="ajtd-rp-content">
<div class="ajtd-rp-featured-image">
<a href="{{ post_url }}" title="{{ post.post_title }} " rel="bookmark">
<img src="{{ featured_image_url }}" alt="{{ post.post_title }}" title="{{ post.post_title }}" srcset="{{ featured_image_srcset }}" />
</a>
</div>
<div>
{{ post.post_title }}
</div>
</div>
</div>
</div>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment