快捷代码不显示分页

时间:2013-10-30 作者:elenakoroleva

我使用一个普通页面通过一个快捷码显示帖子。页面上的帖子显示正确,但不回显下一篇和上一篇帖子的链接,页面内容显示在短代码内容下方。在管理中:

<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">&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\');
和环路调节。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>

1 个回复
SO网友:Prajapati SP

这是一个让ezy u可以在上传你的photogoto html模式后编写此代码,并编写一个

<!--nextpage-->

结束

相关推荐

Custom field within shortcode

我目前正在使用“WP Simple Paypal Shopping Cart”插件建立一个简单的Paypal电子商务网站,它非常容易使用,但为了节省客户编写短代码的时间,我在后端设置了自定义字段以输入产品名称和价格TheAdd to Cart 按钮是使用一段简单的短代码生成的,如下所示:<?php echo print_wp_cart_button_for_product(\'Product Name\', Product Price); ?> 显然正在替换Product Name