I have custom field, array with multiple values

$metas = get_post_meta($post->ID, "$meta_key", false); 
foreach ( $metas as $metas ){
    echo $metas;    

Of course this will return an array.

How to paginate this? So for example:


will return meta_value[0]



will return meta_value[1]

and so on...

1 Answer 1


On a singular view, the current page number can be accessed with get_query_var('page'). You need to subtract 1 to get the corresponding array value. Note that the first page will redirect to the URL without page number, this is just a thing WordPress does.

// get meta
$metas = get_post_meta( $post->ID, 'your_meta_key', false );

// get page number
$page = get_query_var( 'page' );
$page = $page > 1 ? $page - 1 : 0;

// output meta for this page
if( isset( $metas[$page] ) ){
    echo $metas[$page];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.