• I’m trying to query all posts published before the current post and can’t figure out a way to do so. Since date_query is not available as an ALM parameter I’m looking at the alm_query_args_ filter. The problem is that the date_query has to be according to the get_the_date() value of each post. I’ve tried global $post but that’s still not available in the filter. If there is a way to do this in the shortcode that would work. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @ericdev1
    I’m not sure how you would query for posts already loaded.

    I’m a bit confused as to what you’re trying to do, global $post; is available in the Repeater Templates.

    Can you try explaining the exact use case you’re looking for?

    Thread Starter ericdev1

    (@ericdev1)

    @dcooney

    I’ll try to clarify: I have a post from Feb 15, 2020, and at the bottom I want ALM to load all the posts published before Feb 15, 2020. My understanding of the repeater templates is that’s what is loaded after the query is run, so that wouldn’t help, would it? Unless it’s actually ok to put that logic in the repeater template? Thanks for looking at this.

    Plugin Author Darren Cooney

    (@dcooney)

    My understanding of the repeater templates is that’s what is loaded after the query is run, so that wouldn’t help, would it?

    Nope, you’re right. That wouldn’t help.

    You should be using the alm_query_args hook for a date_query. I’m just not sure how you would dynamically get the date_before value

    Thread Starter ericdev1

    (@ericdev1)

    Exactly. I guess I could try echoing the post id in a variable in the head so it’s available in functions.php, I was just trying to avoid using a hack for this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘query posts before current post’ is closed to new replies.