0

I am writing a custom post type for a schedule posting page.

          <section class="schedule">

        <?php 

            $crgs = array(
                'post_type' => 'schedule',
                'posts_per_page' => 20,
                'order' => 'ASC',
            );

            $eventpost = new WP_Query($crgs);

            while($eventpost->have_posts()) {
             $eventpost->the_post();
        ?>

         <div>
              <table>
                  <tr>
                      <td class="the-day">
                          <?php the_title(); ?>
                      </td>
                      <td class="the-place">
                          <?php the_content(); ?>
                      </td>
                  </tr>
              </table>
          </div>
            <?php }
            wp_reset_query(); 
          ?>

      </section>

When I added PHP

                <tr id="post-<?php the_ID(); ?>" 
                    <?php post_class( 'class-name' ) ?>>
                      <td class="the-day">
                          <?php the_title(); ?>
                      </td>
                      <td class="the-place">
                          <?php the_content(); ?>
                      </td>
                  </tr>

for custom ID and class name code to use an odd even loop function

function oddeven_post_class ( $classes ) {
 global $current_class;
 $classes[] = $current_class;
 $current_class = ($current_class == 'odd') ? 'even' : 'odd';
 return $classes;
 }
 add_filter ( 'post_class' , 'oddeven_post_class' );
 global $current_class;
 $current_class = 'odd';

in order to alternate the colors of the event posts to the schedule, the tr remains at 100% width but the two td elements that comprise the date and location of the scheduled event only take up a fraction of the space occupied before the addition of the PHP. I have attempted changing every element of the CSS to increase the width but to no avail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.