Support

Account

Home Forums Feedback Сustom pagination in the custom field

Helping

Сustom pagination in the custom field

  • Hello
    I encountered the problem of displaying custom records in pages by date. I have approximately 400 posts from 2017 to 2019. The date is in a custom field and I take it using the operation $year = date("Y", strtotime(get_field('letter_sent'))); . All posts are displayed on this request

    $posts = get_posts(array(
        'post_type'			=> 'letters',
        'numberposts'	    => -1,
        'meta_key'          => 'letter_sent',
        'meta_type'         => 'NUMERIC',
        'orderby'           => 'meta_value',
    ));

    .
    It is necessary to create a page for 2019 and display entries in which are in the field 2019, for 2018 and so on. Tell me how to implement this since I can’t find a clear answer.
    (sorry for google translate)

  • Hey,
    I really didn’t get the question, but rather than filtering it in the query, you can use this.

    $posts = get_posts(array(
        'post_type'			=> 'letters',
        'numberposts'	    => -1,
    ));
    foreach($posts as $post)
    {
    if(get_field('letter_sent', $post->ID) == '2019')
    {
    //your code
    }
    }

    Also the meta_key is not same when acf saves it. Try enabling the Custom fields option in the Screen options. You will get the idea how acf saves the custom fields.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Сustom pagination in the custom field’ is closed to new replies.