0

This question already has an answer here:

I use a normal page for display posts by a shortcode.On pages posts are displayed correctly,but doesn't echo the next and previous posts links and the page content is displayed below shortcode content. In admin:

<p>page content<p>
[ accomodation-catalog location='slug ' accomodation='slug']

display

<div>shortcode content</div>
<p>page content<p>

What is wrong?

My shortcode in function.php ->

function accomodation_catalog_shortcode( $atts )
{
extract(shortcode_atts(array(
     'accomodation' => '',
     'location'     => '',
     'number'       =>'-1',
     'orderby'      => 'post_date'
   ), $atts));
  $page = (get_query_var('paged')) ? get_query_var('paged') : 1;

$output ='<div class="listings clearfix">' ;    
    global $post;
    $args = array(
    'posts_per_page' => $number, 
    'orderby' => $orderby,
    'paged' => $paged,
    'post_type' => 'accomodation',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'accomodation_category',
            'field' => 'slug',
            'terms' => $accomodation
        ),
        array(
            'taxonomy' => 'location',
            'field' => 'slug',
            'terms' => $location
        )
    )
);
$the_query = new WP_Query( $args );

     while ( $the_query->have_posts() ) {$the_query->the_post(); 

$output .=get_template_part( 'loop', 'accomodation' );
    };
$output .='<div class="nav-previous">' .get_next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts' ) ) . '</div>';
$output .= '<div class="nav-next">' . get_previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>' ) ) . '</div>';
$output .='</div>' ;




wp_reset_query();
   return $output;

}
 add_shortcode('accomodation-catalog', 'accomodation_catalog_shortcode');

and loop-accomodation.php

<div id="post-<?php the_ID(); ?>" class="accomodation-archive">

        <div class="entry-meta">
            <?php saimaanliikenne_entry_meta(); ?>
            <?php edit_post_link( __( 'Редактировать', 'saimaanliikenne' ), '<span class="edit-link">', '</span>' ); ?>
        </div><!-- .entry-meta -->

    <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
            <?php the_post_thumbnail( 'preview' );?>
        <?php endif; ?> 
        <!--вывод информации из пользовательских полей-->
<div class="accomodation-archive-content">
        <?php if (get_post_meta( $post->ID, 'bbcosta_alt_title', true )!=='')://если есть альтернативное название выводит его,если нет title ?>
        <h2 class="accomodation-archive-title">
        <a href="<?php the_permalink(); ?>" rel="bookmark">
        <?php echo get_post_meta( $post->ID, 'bbcosta_alt_title', true ); ?></a></h2>

        <?php else : ?>
        <h2 class="accomodation-archive-title">
            <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
        </h2>
        <?php endif;?> 
     <div class="location-info">
    <?php echo get_post_meta( $post->ID, 'bbcosta_hotel_location', true ); ?><?php echo get_hotel_star(); ?> 
    </div>

     <?php if ((get_post_meta( $post->ID, 'bbcosta_number_person', true )|get_post_meta( $post->ID, 'bbcosta_area', true ))!==''){?>
     <p class="accommodation-info">
     <?php if (get_post_meta( $post->ID, 'bbcosta_number_person', true )!==''){?>
    <?php echo get_post_meta( $post->ID, 'bbcosta_number_person', true );?>,<?php } ?><?php echo get_post_meta( $post->ID, 'bbcosta_area', true );  ?>
    </p>
    <?php } ?>
    <?php if ((get_post_meta( $post->ID, 'bbcosta_bedrooms', true )|get_post_meta( $post->ID, 'bbcosta_advantage', true ))!==''){?>
     <p class="accommodation-info">
     <?php if (get_post_meta( $post->ID, 'bbcosta_bedrooms', true )!==''){?>
    <?php echo get_post_meta( $post->ID, 'bbcosta_bedrooms', true );?>,<?php } ?><?php echo get_post_meta( $post->ID, 'bbcosta_advantage', true );  ?>
    </p>
    <?php } ?>

     <?php if (get_post_meta( $post->ID, 'bbcosta_alt_description', true )!==''){?>
     <p class="alt-description">
    <?php echo get_post_meta( $post->ID, 'bbcosta_alt_description', true ); ?>
    </p>
    <?php } ?>
    <?php if (get_post_meta( $post->ID, 'bbcosta_price', true )!==''){?>
    <div class="accomodation-price">
    <?php if (get_post_meta( $post->ID, 'bbcosta_old_price', true )!==''){?>
    <span class="line-through">
    <?php echo get_post_meta( $post->ID, 'bbcosta_old_price', true ); ?></span> / <?php } ?><span>
    <?php echo get_post_meta( $post->ID, 'bbcosta_price', true ); ?></span></div> <?php } ?>
</div>
</div>

marked as duplicate by Chip Bennett, fuxia Oct 30 '13 at 14:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

-1

Its a so ezy u can write this code after upload your photo goto html mode and write a

<!--nextpage-->

Not the answer you're looking for? Browse other questions tagged or ask your own question.