dqx76962 2013-05-22 06:10
浏览 43

如何创建自定义wordpress库

Youtube link for make it easy to understand : http://www.youtube.com/watch?v=9by-igzg6Ms

I just need a group of images in wordpress so i could link images with next one. I am not professional in Wordpress, i am getting a problem while creating custom wordpress gallery plugins, please help me if any one can it's last day of my project and i have tried most of articles, stackoverflow question and answer but got nothing related to this.

Here is code also i am getting issue while more page button but that might be because i haven't created page for that.

function add_gallery_shortcode($atts, $content = null) {
$a = shortcode_atts(array(
    'gallery_name' => '',
    'sub_gallery' => '',
    'per_page' => 4,
        ), $atts);

$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array('post_type' => $a['gallery_name'], 'posts_per_page' => $a['per_page'], 'paged' => $paged);

$loop = new WP_Query($args);

?>

<?php while ($loop->have_posts()) : $loop->the_post(); ?>

<?php echo '<div class="thumbs">' . wp_get_attachment_link(get_post_thumbnail_id(), 'thumbnail') . '</div>';

endwhile;

echo '<div id="nav_next_previous">
<div id="next">' .
    next_posts_link('More »', $loop->max_num_pages) . '
</div>
<div id="prev">' .
    previous_posts_link('« Previous', $loop->max_num_pages) . '
</div>
</div><!-- thumbs-nextpage-wrap close-->';}

I am also attaching youtube video link how it will be looks like, i don't know how i can create link for next group of images. if there will be any free plugin for that will be also helpful.

Thanks

  • 写回答

1条回答 默认 最新

  • douqujin2767 2013-05-22 07:41
    关注

    next_posts_link and previous_posts_link are used inside the loop for getting next or previous single post link.

    You have to use paginate_links function instead of next_posts_link

    e.g.

       echo paginate_links( array(
          'format' => '?paged=%#%',
          'current' => max( 1, get_query_var('paged') ),
          'total' => $loop->max_num_pages,
          'prev_text' => '« Previous',
          'next_text' => 'More »',
       ) );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100