我使用一个普通页面通过一个快捷码显示帖子。页面上的帖子显示正确,但不回显下一篇和上一篇帖子的链接,页面内容显示在短代码内容下方。在管理中:
<p>page content<p>
[ accomodation-catalog location=\'slug \' accomodation=\'slug\']
显示器
<div>shortcode content</div>
<p>page content<p>
怎么了?
函数中的我的短代码。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">←</span> Older posts\' ) ) . \'</div>\';
$output .= \'<div class="nav-next">\' . get_previous_posts_link( __( \'Newer posts <span class="meta-nav">→</span>\' ) ) . \'</div>\';
$output .=\'</div>\' ;
wp_reset_query();
return $output;
}
add_shortcode(\'accomodation-catalog\', \'accomodation_catalog_shortcode\');
和环路调节。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>