Hi jeffdoan06
Is this a specific date or a period of time?
Did you checkout the limit month parameter?
https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/#limit-month
Yes this would work — we’ll prolly need to update it every month, but this’ll work. Is there a way to limit posts to only after X month?
Thanks for the reply!
Are you using the widget or shortcode, or both?
Neither — including it in functions.php
Can you post the code you use in functions.php here.
add_filter( 'the_content', 'add_related_posts_after_post_content' );
function add_related_posts_after_post_content( $content ) {
//check if it's a single post page.
if ( is_single() ) {
// check if we're inside the main loop
if ( in_the_loop() && is_main_query() ) {
// add your own attributes here (between the brackets [ ... ])
$shortcode = '[related_posts_by_tax posts_per_page="4" orderby="post_date"]';
// add the shortcode after the content
$content = $content . $shortcode;
}
}
return $content;
}
Thanks — I just used sample code here, but I’m just trying to figure out the best filter to use here =)
Also how do I change the template used with the above function?
Update: figured this part out =)
Try changing this:
// add your own attributes here (between the brackets [ ... ])
$shortcode = '[related_posts_by_tax posts_per_page="4" orderby="post_date"]';
To this:
// add your own attributes here (between the brackets [ ... ])
$shortcode = '[related_posts_by_tax posts_per_page="4" limit_month="1"]';
This will search for related posts published in the last month.