Miva Merchant Modules and Development
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.

SCOTSBLOGGER: Load Posts Two Weeks Old and Display

Scot Ranney • November 06, 2024


Display links to posts that are up to two weeks old. Change the code below for any time span you want.

This is useful for auto content on SFNT - good for SEO to have changing home page content.

1. Make sure scotsblogger page item is assigned to the SFNT or template being used for this.

2. The following code loads the posts into an array:

<mvt:comment>
#
# set up an array of posts within the last two weeks and display them above the "what module do you want" biz
# Find the blog id in the blog list
# Change 14 to whatever day span you want
#
</mvt:comment>

<mvt:assign name="g.blog_id" value="1" />
<mvt:assign name="l.days" value="14" />

<mvt:item name="scotsblogger" />

<mvt:item name="scotsblogger" param="recent posts" />
<mvt:foreach iterator="post" array="scotsblogger:posts">
	<mvt:if expr="l.settings:post:publish_t GT (s.dyn_time_t - (86400 * l.days))">
		<mvt:assign name="l.ok" value="miva_array_insert(l.settings:fposts,l.settings:post,-1)" />
	<mvt:else>
		<mvt:foreachstop />
	</mvt:if>
</mvt:foreach>

3. The following code will display the posts:

<mvt:foreach iterator="fpost" array="fposts">
	<mvt:if expr="l.pos1 EQ 1">
		<h2 class="h4 mb-3">News and Updates:</h2>
	</mvt:if>
	<p class="mb-3">
		<a class="text-decoration-none fw-bold" href="&mvt:fpost:url;">
			&mvt:fpost:title;, &mvt:fpost:updatedparsed:month_str; &mvt:fpost:updatedparsed:day;, &mvt:fpost:updatedparsed:year;
		</a>
		

		<span class="text-secondary">&mvt:fpost:synopsis;</span>
	</p>
</mvt:foreach>

https://www.scotsscripts.com/mvblog/scotsblogger-load-posts-two-weeks-old-and-display.html

mvkb_scotsblogger