Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Shortcode displaying on top of content always

Discussion in 'Misc WordPress Requests' started by Tiger, Mar 19, 2018.

  1. Tiger

    Guest

    Shortcode displaying on top of content always, by Tiger

    I’ve created a shortcode but the shortcode always displaying top of the content. Here is my shortcode function –

    function featured_posts_shortcode() { ?>
    <div class="g-cols offset_small">
    <?php query_posts ( array( 'tag' => 'featured', 'posts_per_page' => 3 )); ?>
    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <div class="featured-item grid-33">
    <article <?php post_class(); ?>>
    <div class="featured-item-inner">
    <div class="featured-item-title">
    <?php the_title(); ?>
    </div>
    </div>
    </article>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>
    </div>
    <?php
    }
    add_shortcode('featured-list', 'featured_posts_shortcode');

    Please help me with correct code. I have searched everywhere but no luck!

    Shortcode displaying on top of content always
     
    #1

Share This Page

Monarch Social Sharing Plugin