October 12, 2021 at 11:02 am #1324513
Hey folks, I am wondering if it is possible with the Blog Posts Element to show only blog posts of one month?! Not by an actual date, that is possible, I know, but with an parameter like “last 30 days” or anything like that. If I set a start date in the Blog Post Element the list of posts is growing from this day on. It doesn’t change. If I could set an option like “all posts from the last X days” I could build a real archive. For example one for the visitors with all entries from the last 30 days and one for members with all posts older than 30 days or anything like that. Is there an option that I didn’t find or any code I could use to get an option like that in the Blog Posts Element? Would be great to get an answer from you as they are always helpful. Thanks in advance!October 12, 2021 at 1:41 pm #1324556
Thank you for the inquiry.
You should be able to use the date_query parameter to retrieve posts that were published from the last 30 days. An example can be found in the following article.
'date_query' => array( array( 'after' => '-30 days', 'column' => 'post_date', ),
You can use the avia_blog_post_query filter to adjust the blog posts query.
IsmaelOctober 12, 2021 at 2:05 pm #1324568
thanks for your fast response. Wouldn’t anything like that affect the whole blog? I would like to set it only on one page for a certain Blog Post Element. Is this possible with the given example?
All the best,
DanielOctober 13, 2021 at 1:12 am #1324655
Thank you for the update.
I would like to set it only on one page for a certain Blog Post Element
Yes, that should be possible. You can use conditional functions such as is_page or is_single within the query filter to only apply the changes to a specific page or blog posts element.
IsmaelOctober 13, 2021 at 9:17 am #1324693
Thank you! I could have come up with that myself. Thanks for the links. But maybe it would also be an idea to incorporate such a solution in the future. With startdate you would only have to be able to specify a period instead of a specific date. Can I make a feature request for this somewhere?October 14, 2021 at 8:08 am #1324859
No problem! We will forward your request to our channel but we cannot promise that this will be included in the latest patch or the next.
Thank you for your patience.
IsmaelOctober 14, 2021 at 2:22 pm #1324934
Thanks! I am using your theme for quite some years and a lot of cusomters by now. Had the need for this option many times, found some workarounds but a real solution would be way better. Keep looking forward to spot it in the changelog someday in the future.
You may close this for now. Kind regards, DanielOctober 16, 2021 at 3:30 am #1325189
Alrighty! Thank you for using the theme for so many years and for the continued support. Really appreciate it. We have already forwarded the request to our channel, so hopefully this feature will finally be included in the upcoming versions. We will close the thread for now.
Have a nice day.
- The topic ‘Show only blog posts of one month’ is closed to new replies.