• So is it possible to return the count of years in a post query?

    So if i produce a post query and there is a post created every year for five years..then the count would = 5?

    Maybe it would be similar to this:

    <?php  $paged = get_query_var( 'paged', 1 );  ?>
    
    <h1>Currently Browsing Page <?php echo (int) $paged; ?></h1>

    but would return the count of years present in a query.

    Thank You!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    You mean to echo a posts age?

    Thanks,
    Artur

    Thread Starter alionsfeather

    (@alionsfeather)

    Hey Artur, thanks for responding

    I guess if I can explain a little better..

    when i produce a post query I can pull up all of my blogs posts into a single page. These posts creation date range from 2016 to 2014. if possible , i would like to store the count of that range of years.

    so in this instance , for a query of all my posts there is 2016, 2015, and 2014 or in other words 3 years of posts.

    My guess is that the post query stores the years in an array and if so I just need the length of that array.

    maybe this is a better explanation. Im new to php so i apologize if i am failing to get my point across

    Hi,

    No need for apology, I completely understand and everyone is at their own level of knowledge. That said and looking at your code example, your looking to display post based on their year. Sort of like pagination yearly vs pages. So normally the query would bring bunch of posts back but list them pages by 10s or whatever.

    You want to bring a query back and figure out how to page them by year they are from. Correct?

    I’m sorry if I’m not getting it right.

    Maybe this is what you are after? https://keesiemeijer.wordpress.com/date-pagination

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘return count of years in query’ is closed to new replies.