Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Dennis Eitner
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dennis Eitner
Full Stack JavaScript Techdegree Graduate 25,644 Points

content after shortcode

My shortcode gets displayed before the_content(); I don't know how to fix it. Any help anyone?

here is the shortcode:

function portfolio_showcase() {
    $portfolio  = get_template_part('portfolio');
    return $portfolio;
}
add_shortcode( 'portfolio', 'portfolio_showcase' );

This is the template part:

<?php
    $args = array( 'post_type' => 'work', 'posts_per_page' => -1 );
    $loop = new WP_Query( $args );
?>

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="card-grid">
    <div class="front">  <?php the_post_thumbnail(array(150,350)); ?></div>
        <div class="back">
            <h4><?php the_title();?></h4>
            <p><?php the_field('description');?></p>
            <p> <?php the_tags(); ?></p>
            <a href="<?php the_permalink();?>" class="btn btn-dark" target="_blank">More</a>
        </div>
    </div>
<?php endwhile; ?>

This is the loop:

<?php
    $args = array( 'post_type' => 'frontpage', 'posts_per_page' => -1 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
 ?>

<section id="<?php echo $post->post_name; ?>" class="about">
    <div class="container">
        <div class="row">
            <div class="col-lg-12 text-center">
                <h2><?php the_title(); ?></h2>
                    <?php the_content(); ?>
            </div>
        </div>
        <hr>
    </div>
</section>

<?php endwhile;  ?>