Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ajtatum
Created January 28, 2022 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajtatum/e141af8edbb27a28d47352c7e9660749 to your computer and use it in GitHub Desktop.
Save ajtatum/e141af8edbb27a28d47352c7e9660749 to your computer and use it in GitHub Desktop.
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