• Ok, so I am using Events Calendar Pro by Modern Tribe to organize events. We created a custom meta field called rhc-button-text to allow us to overwrite the standard “Read More” text of the button, for instance “Buy Tickets” or “Register Now”… But in case the client goofs-up and doesn’t enter anything in this field, I still want it to say “Read More”

    I don’t know PHP, and I’ve inherited the site from someone else… I am sure it’s as simple as “check if there’s a value” if not “echo Read More”… but I don’t know the syntax. Can someone help me out here?

    <ul class="evslide">
    <?php
        // Get all events between specific date range
        global $post;
        $CurrentDate = date('2014-09-06 00:00:00');
        $EndDate = date('2014-09-14 23:59:59');
            $events_today = tribe_get_events(
            array(
                'start_date'=>$CurrentDate,
                'end_date'=>$EndDate
                )
        );
    
            foreach($events_today as $post) {
            setup_postdata($post);
            ?>
            <?php if ( has_post_thumbnail() ) { ?>
            <li>
                <div class="thumbList">
                    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('medium', array('class' => 'scale-with-grid attachment-thumbnail')); ?></a>
                </div>
                <div class="event-excerpt">
                    <h6 class="event-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a><p class="front-start-time"><?php echo tribe_get_start_date( $post->ID, false, 'M d, g:i a' ); ?> - <?php echo tribe_get_end_date( $post->ID, false, 'g:i a' ); ?> </p></h6>
    
        // Show button with custom text.
    
                    <a class="btn-small" href="<?php the_permalink(); ?>"><?php echo get_post_meta($post->ID,'rhc-button-text',true) ?></a>
                </div>
                <div class="clear"></div></li>
    </ul>
  • The topic ‘Simple PHP Question: Check if meta has value, if not show "Read More"’ is closed to new replies.