• Resolved sakarya

    (@sakarya)


    hello.

    I’ve created a group fields. how can I add pagination for it?

    I want to show 1 item per request.

    output code:

    $ozellikler = get_post_meta( get_the_ID(), 'gallery_gallery_group', true );
    foreach ( (array) $ozellikler as $key => $entry ) {
    
    $img_title = $img_image = $img_text = '';
    
    					if ( isset( $entry['img_title'] ) )
    						$img_title = esc_html( $entry['img_title'] );
    
    					if ( isset( $entry['img_text'] ) )
    						$img_text = wpautop( $entry['img_text'] );
    
    					if ( isset( $entry['img_image'] ) ) {
    						$img_image = wp_get_attachment_image( $entry['img_image_id'], 'full', null, array(
    							'class' => 'img-responsive',
    						) );
    					}
    					echo "
    
    <li>";
    					echo $img_image;
    					echo '<h5 style="font-weight:bold;">'.$img_title.'</h5>';
    					echo $img_text;
    					echo "</li>
    ";
    				}

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    https://wordpress.org/plugins/cmb2/

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’d be surprised if Justin had anything built in for this type of request, to be honest.

    That said, I believe you could accomplish it to some degree if you did something with the URL so that it holds a number indicating the page, and if you set up the post meta fields to have an incremental number in it as well.

    The number could be fetched out of the URL and used in the meta_key to choose which one to display.

    $page = absint( $_GET['pagenumber'] );
    
    # Fetches the meta key corresponding to the number from the meta key
    $item = get_post_meta( get_the_ID(), 'my_meta_key_' . $page, true );

    Just some quick thoughts to maybe stimulate some ideas for ya.

Viewing 1 replies (of 1 total)
  • The topic ‘pagination for groups’ is closed to new replies.