[resolved] Twenty Fourteen display custom post type in two column layout (4 posts)

  1. carbfrze
    Posted 2 years ago #

    Hello all WordPress experts! I am trying to display a custom post type and have the query display in a two column table format on the page. Currently I've been able to get it to display in separate rows but not columns and the table displays twice for some reason. I know this may involve some serious coding and I am fairly adept at PHP but am still learning. Here is the link to the page in question: http://new.ynp2.com/pet-list/ Below is the code that I currently have, any help would be appreciated:

                <?php $listings = new WP_Query( array('post_type' => 'phanimals') ); if( $listings->have_posts() ): while($listings->have_posts()): $listings->the_post(); ?>
                                        // now get and display custom fields
                                        $tour_custom_fields = get_post_custom();
                                        if (trim($tour_custom_fields['Pup Name']['0']) != "") { ?>
                                               <h4><? echo $tour_custom_fields['Pup Name']['0']; ?></h4>
    // Page thumbnail and title.
    <?php }
               if (trim($tour_custom_fields['Date of Birth']['0']) != "") {
                        $tmpage = calculate_age_from_dob($tour_custom_fields['Date of Birth']['0']);
                        $tmpdob = calculate_friendly_dob($tour_custom_fields['Date of Birth']['0']);
                        echo '<span class="attrname">Age: </span><span class="attrval">' . $tmpage . '</span><br>';
                        echo '<span class="attrname">D.O.B.: </span><span class="attrval">' . $tmpdob . '</span><br>';
    <?php echo get_the_term_list( $post->ID, 'animal_species', 'Species: ', ', ', '</p>' ); ?>
    <?php echo get_the_term_list( $post->ID, 'animal_gender', 'Gender: ', ', ', '</p>' ); ?>
    <?php echo get_the_term_list( $post->ID, 'animal_allergy_scales', 'Allergy Scale: ', ', ', '</p>' ); ?>
    <?php echo get_the_term_list( $post->ID, 'animal_activity_levels', 'Activity Level: ', ', ', '</p>' ); ?>
    <?php echo get_the_term_list( $post->ID, 'shedding', 'Shedding: ', ', ', '</p>' ); ?>
    <?php echo get_the_term_list( $post->ID, 'weight_range', 'Weight Range: ', ', ', '&nbsp;lbs.</p>' ); ?>
    <?php echo get_the_term_list( $post->ID, 'expected_size', 'Expected Size: ', ', ', '&nbsp;lbs.</p>' ); ?>
        <div class="entry-content3">
                        wp_link_pages( array(
                                'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
                                'after'       => '</div>',
                                'link_before' => '<span>',
                                'link_after'  => '</span>',
                        ) );
                        edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
        </div><!-- .entry-content -->
    </article><!-- #post-## -->
                <?php endwhile; endif; ?>
  2. carbfrze
    Posted 2 years ago #

    Nevermind. I figured it out myself. Reference can be found here for anybody that is wondering. I tried both methods and both worked, however the alignment was easier to adjust in the CSS version.

  3. esmi
    Forum Moderator
    Posted 2 years ago #

    Do not edit the Twenty Fourteen theme. It is the current default WordPress theme and having access to an original, unedited, copy of the theme is vital in many situations. First create a child theme for your changes.

  4. carbfrze
    Posted 2 years ago #

    Yes I had done that as soon as I started designing the site. Sorry I didn't mention that. I have this in a child theme and it is working fine now.

Topic Closed

This topic has been closed to new replies.

About this Topic