• Resolved j09

    (@j09)


    I cannot figure out how to display more than 5 custom fields for each listing. I have tried deleting the fields and adding them again, flipping the order and a few other things.

    It seems that custom fields are limited to display only 5 on the listings page. The issue does not exist in the single listing page as all of them display just fine.

    The code I used to add the custom fields to the items in the listings page is this:

    <?php
    $category = wp_get_object_terms( $post->ID, 'acadp_categories' );
    
    // get custom fields
    $args = array(
        'post_type' => 'acadp_fields',
        'tax_query' => array(
            array(
    	    'taxonomy' => 'acadp_categories',
    	    'field'    => 'term_id',
    	    'terms'    => $category[0]->term_id,
           ),
        ),
        'meta_key'  => 'order',
        'order_by'  => 'meta_value_num',
        'order'     => 'ASC',
    );
    
    $fields = get_posts( $args );
    ?>
    
    <?php if( count( $fields ) ) : ?>
        <ul class="list-group acadp-margin-bottom">
            <?php foreach( $fields as $field )  : ?>
                <?php if( $value = get_post_meta( $post->ID, $field->ID, true ) ) : ?>
        	        <li class="list-group-item acadp-no-margin-left">
                        <span class="text-primary"><?php echo $field->post_title; ?></span> :
    		    <span class="text-muted"><?php echo $value; ?></span>
                   </li>
               <?php endif; ?>
           <?php endforeach; ?>
        </ul>
    <?php endif; ?>

    which you kindly provided in a another support question here.

    So, where can I control the number of custom fields that get displayed on the listings page?

    Thank you.

    • This topic was modified 7 years, 6 months ago by j09.
    • This topic was modified 7 years, 6 months ago by j09.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pluginsware

    (@pluginsware)

    Try using the following code,

    <?php
    $category = wp_get_object_terms( $post->ID, 'acadp_categories' );
    
    // get custom fields
    $args = array(
        'post_type' => 'acadp_fields',
        'posts_per_page' => -1,
        'tax_query' => array(
            array(
    	    'taxonomy' => 'acadp_categories',
    	    'field'    => 'term_id',
    	    'terms'    => $category[0]->term_id,
           ),
        ),
        'meta_key'  => 'order',
        'order_by'  => 'meta_value_num',
        'order'     => 'ASC',
    );
    
    $fields = get_posts( $args );
    ?>
    
    <?php if( count( $fields ) ) : ?>
        <ul class="list-group acadp-margin-bottom">
            <?php foreach( $fields as $field )  : ?>
                <?php if( $value = get_post_meta( $post->ID, $field->ID, true ) ) : ?>
        	        <li class="list-group-item acadp-no-margin-left">
                        <span class="text-primary"><?php echo $field->post_title; ?></span> :
    		    <span class="text-muted"><?php echo $value; ?></span>
                   </li>
               <?php endif; ?>
           <?php endforeach; ?>
        </ul>
    <?php endif; ?>
    • This reply was modified 7 years, 5 months ago by pluginsware.
    Thread Starter j09

    (@j09)

    That worked great. Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display more than 5 custom fields on each listing on the listings page?’ is closed to new replies.