• I’m using the following code to display a custom post type panel in the sidebar using the PHP Code widget.

    <?php
    $loop = new WP_Query( array( 'post_type' => 'spotlight', 'posts_per_page' => 1 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
    $data = get_post_meta( $post->ID, 'spotlight', true );
    echo '<div class="spotlight-content">';
    echo '<a href="';
    <?php echo $data[ 'spotlighturl' ]; ?>
    echo '">';
     the_post_thumbnail();
    echo '</a>';
    echo '<h3 class="hitme">';
    echo '<a href="';
    the_permalink();
    echo '">';
    the_title('', '');
    echo '</a>';
    echo '</h3>';
      the_content();
      echo '</div>';
    endwhile;
    ?>

    I can’t seem to get the following to pass as a link:
    <?php echo $data[ 'spotlighturl' ]; ?>

    Can someone help me figure out what I’m doing wrong? I need to figure this out before 4pm EST today and no one in-house can help me.

  • The topic ‘Using WP_Query in PHP Code Widget: Getting Custom Meta Box Content’ is closed to new replies.