Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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!

    #1324556

    Hey spooniverse,

    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.

    // https://hirejordansmith.com/how-to-get-posts-published-in-the-last-30-days-using-wp_query/

     '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.

    Best regards,
    Ismael

    #1324568

    Hi Ismael,
    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,
    Daniel

    #1324655

    Hi,

    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.

    // https://developer.wordpress.org/reference/functions/is_page/

    Best regards,
    Ismael

    #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?

    #1324859

    Hi,

    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.

    Best regards,
    Ismael

    #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, Daniel

    #1325189

    Hi,

    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.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Show only blog posts of one month’ is closed to new replies.