默认wordpress库分页

默认wordpress库分页,wordpress,pagination,gallery,default,Wordpress,Pagination,Gallery,Default,我正在到处寻找一个插件,通过分页将包含80张照片的默认WordPress 3.8.3图库分成4页20张照片。我已经在网上找了两天了,但是没有找到任何东西。。。有人知道插件吗 谢谢我不确定你是否设法解决了这个问题。我确实有一个解决办法 以下是我所做的: 首先在wordpress后端的特定页面上创建库。然后在我的functions.php文件中添加了以下代码: add_filter('post_gallery', 'filter_gallery', 10, 2); function filter_g

我正在到处寻找一个插件,通过分页将包含80张照片的默认WordPress 3.8.3图库分成4页20张照片。我已经在网上找了两天了,但是没有找到任何东西。。。有人知道插件吗


谢谢

我不确定你是否设法解决了这个问题。我确实有一个解决办法

以下是我所做的: 首先在wordpress后端的特定页面上创建库。然后在我的functions.php文件中添加了以下代码:

add_filter('post_gallery', 'filter_gallery', 10, 2);
function filter_gallery($output, $attr) 
{
    global $post;



    //GALLERY SETUP STARTS HERE----------------------------------------//
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby'])
            unset($attr['orderby']);
    }
    //print_r($attr);
    extract(shortcode_atts(array(
        'order' => 'ASC',
        'orderby' => 'menu_order ID',
        'id' => $post->ID,
        'itemtag' => 'dl',
        'icontag' => 'dt',
        'captiontag' => 'dd',
        'columns' => 3,
        'size' => 'thumbnail',
        'include' => '',
        'exclude' => ''
    ), $attr));

    $id = intval($id);
    if ('RAND' == $order) $orderby = 'none';

    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));

        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    }
    if (empty($attachments)) return '';
    //GALLERY SETUP END HERE------------------------------------------//





    //PAGINATION SETUP START HERE-------------------------------------//
    $current = (get_query_var('paged')) ? get_query_var( 'paged' ) : 1;
    $per_page = 24;
    //$offset = ($page-1) * $per_page;
    $offset = ($current-1) * $per_page;
    $big = 999999999; // need an unlikely integer


    $total = sizeof($attachments);
    $total_pages = round($total/$per_page);
    if($total_pages < ($total/$per_page))
    {   $total_pages = $total_pages+1;
    }
    //PAGINATION SETUP END HERE-------------------------------------//














    //GALLERY OUTPUT START HERE---------------------------------------//
    $output = "<div class=\"gallery-images\">\n";
    $counter = 0;
    $pos = 0;
    foreach ($attachments as $id => $attachment) 
    {   $pos++;
        //$img = wp_get_attachment_image_src($id, 'medium');
        //$img = wp_get_attachment_image_src($id, 'thumbnail');
        //$img = wp_get_attachment_image_src($id, 'full');  

        if(($counter < $per_page)&&($pos > $offset))
        {   $counter++;
            $largetitle = get_the_title($attachment->ID);
            $largeimg = wp_get_attachment_image_src($id, 'large');  
            $img = wp_get_attachment_image_src($id, array(100,100));        
            $output .= " <a href=\"{$largeimg[0]}\" data-lightbox=\"example-set\" title=\"{$largetitle}\"><img src=\"{$img[0]}\" width=\"{$img[1]}\" height=\"{$img[2]}\" alt=\"\" /></a>\n";
        }

    }  
    $output .= "<div class=\"clear\"></div>\n";
    $output .= "</div>\n";
    //GALLERY OUTPUT ENDS HERE---------------------------------------//






    //PAGINATION OUTPUT START HERE-------------------------------------//
    $output .= paginate_links( array(
        'base' => str_replace($big,'%#%',esc_url(get_pagenum_link($big))),
        'format' => '?paged=%#%',
        'current' => $current,
        'total' => $total_pages,
        'prev_text'    => __('&laquo;'),
        'next_text'    => __('&raquo;')
    ) );
    //PAGINATION OUTPUT ENDS HERE-------------------------------------//





    return $output;
}
add_filter('post_gallery','filter_gallery',10,2);
函数过滤器\u库($output,$attr)
{
全球$员额;
//画廊设置从这里开始----------------------------------------//
如果(isset($attr['orderby'])){
$attr['orderby']=sanitize_sql_orderby($attr['orderby']);
如果(!$attr['orderby'])
未设置($attr['orderby']);
}
//打印费用($attr);
提取(短码)附件(数组)(
“订单”=>“ASC”,
'orderby'=>'菜单\u订单ID',
'id'=>$post->id,
'itemtag'=>'dl',
'icontag'=>'dt',
'captiontag'=>'dd',
“列”=>3,
“大小”=>“缩略图”,
'包括'=>'',
“排除”=>“
)美元(attr);;
$id=intval($id);
如果('RAND'=$order)$orderby='none';
如果(!空($include)){
$include=preg_replace(“/[^0-9,]+/”,“$include”);
$\u attachments=get\u posts(数组('include'=>$include',post\u status'=>'inherit','post\u type'=>'attachment','post\u mime\u type'=>'image','order'=>$order',orderby'=>$orderby));
$attachments=array();
foreach($\附件为$key=>$val){
$attachments[$val->ID]=$\附件[$key];
}
}
if(空($attachments))返回“”;
//画廊设置到此结束------------------------------------------//
//分页设置从这里开始-------------------------------------//
$current=(get_query_var('paged'))?get_query_var('paged'):1;
每页$24;
//$offset=($page-1)*$每页;
$offset=($current-1)*$每页;
$big=99999999;//需要一个不太可能的整数
$total=sizeof($attachments);
$total_pages=圆形($total/$per_pages);
如果($总页数<($总页数/$每页))
{$total_pages=$total_pages+1;
}
//分页设置在此结束-------------------------------------//
//画廊输出从这里开始---------------------------------------//
$output=“\n”;
$counter=0;
$pos=0;
foreach($id=>$attachment的附件)
{$pos++;
//$img=wp_get_attachment_image_src($id,'medium');
//$img=wp_get_attachment_image_src($id,'thumbnail');
//$img=wp_get_attachment_image_src($id,'full');
如果(($counter<$per_page)和($pos>$offset))
{$counter++;
$largetitle=获取标题($attachment->ID);
$largeimg=wp_get_attachment_image_src($id,'large');
$img=wp_get_attachment_image_src($id,数组(100100));
$output.=“\n”;
}
}  
$output.=“\n”;
$output.=“\n”;
//画廊输出到此结束---------------------------------------//
//分页输出从这里开始-------------------------------------//
$output.=分页链接(数组(
'base'=>str_replace($big,%#%',esc_url(get_pagenum_link($big)),
'格式'=>'?分页=%#%',
“当前”=>$current,
“总计”=>$total\u页,
“上一个文本”=>“«;”,
“下一个文本”=>“»;”)
) );
//分页输出在此结束-------------------------------------//
返回$output;
}

希望这有帮助

我不确定你是否设法解决了这个问题。我确实有一个解决办法

以下是我所做的: 首先在wordpress后端的特定页面上创建库。然后在我的functions.php文件中添加了以下代码:

add_filter('post_gallery', 'filter_gallery', 10, 2);
function filter_gallery($output, $attr) 
{
    global $post;



    //GALLERY SETUP STARTS HERE----------------------------------------//
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby'])
            unset($attr['orderby']);
    }
    //print_r($attr);
    extract(shortcode_atts(array(
        'order' => 'ASC',
        'orderby' => 'menu_order ID',
        'id' => $post->ID,
        'itemtag' => 'dl',
        'icontag' => 'dt',
        'captiontag' => 'dd',
        'columns' => 3,
        'size' => 'thumbnail',
        'include' => '',
        'exclude' => ''
    ), $attr));

    $id = intval($id);
    if ('RAND' == $order) $orderby = 'none';

    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));

        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    }
    if (empty($attachments)) return '';
    //GALLERY SETUP END HERE------------------------------------------//





    //PAGINATION SETUP START HERE-------------------------------------//
    $current = (get_query_var('paged')) ? get_query_var( 'paged' ) : 1;
    $per_page = 24;
    //$offset = ($page-1) * $per_page;
    $offset = ($current-1) * $per_page;
    $big = 999999999; // need an unlikely integer


    $total = sizeof($attachments);
    $total_pages = round($total/$per_page);
    if($total_pages < ($total/$per_page))
    {   $total_pages = $total_pages+1;
    }
    //PAGINATION SETUP END HERE-------------------------------------//














    //GALLERY OUTPUT START HERE---------------------------------------//
    $output = "<div class=\"gallery-images\">\n";
    $counter = 0;
    $pos = 0;
    foreach ($attachments as $id => $attachment) 
    {   $pos++;
        //$img = wp_get_attachment_image_src($id, 'medium');
        //$img = wp_get_attachment_image_src($id, 'thumbnail');
        //$img = wp_get_attachment_image_src($id, 'full');  

        if(($counter < $per_page)&&($pos > $offset))
        {   $counter++;
            $largetitle = get_the_title($attachment->ID);
            $largeimg = wp_get_attachment_image_src($id, 'large');  
            $img = wp_get_attachment_image_src($id, array(100,100));        
            $output .= " <a href=\"{$largeimg[0]}\" data-lightbox=\"example-set\" title=\"{$largetitle}\"><img src=\"{$img[0]}\" width=\"{$img[1]}\" height=\"{$img[2]}\" alt=\"\" /></a>\n";
        }

    }  
    $output .= "<div class=\"clear\"></div>\n";
    $output .= "</div>\n";
    //GALLERY OUTPUT ENDS HERE---------------------------------------//






    //PAGINATION OUTPUT START HERE-------------------------------------//
    $output .= paginate_links( array(
        'base' => str_replace($big,'%#%',esc_url(get_pagenum_link($big))),
        'format' => '?paged=%#%',
        'current' => $current,
        'total' => $total_pages,
        'prev_text'    => __('&laquo;'),
        'next_text'    => __('&raquo;')
    ) );
    //PAGINATION OUTPUT ENDS HERE-------------------------------------//





    return $output;
}
add_filter('post_gallery','filter_gallery',10,2);
函数过滤器\u库($output,$attr)
{
全球$员额;
//画廊设置从这里开始----------------------------------------//
如果(isset($attr['orderby'])){
$attr['orderby']=sanitize_sql_orderby($attr['orderby']);
如果(!$attr['orderby'])
未设置($attr['orderby']);
}
//打印费用($attr);
提取(短码)附件(数组)(
“订单”=>“ASC”,
'orderby'=>'菜单\u订单ID',
'id'=>$post->id,
'itemtag'=>'dl',
'icontag'=>'dt',
'captiontag'=>'dd',
“列”=>3,
“大小”=>“缩略图”,
'包括'=>'',
“排除”=>“
)美元(attr);;
$id=intval($id);
如果('RAND'=$order)$orderby='none';
如果(!空($include)){
$include=preg_replace(“/[^0-9,]+/”,“$include”);
$\u attachments=get\u posts(数组('include'=>$include',post\u status'=>'inherit','post\u type'=>'attachment','post\u mime\u type'=>'image','order'=>$order',orderby'=>$orderby));
$attachments=array();
foreach($\附件为$key=>$val){
$attachments[$val->ID]=$\附件[$key];
}
}
if(空($attachments))返回“”;
//画廊设置到此结束------------------------------------------//
//分页设置从这里开始-------------------------------------//
$current=(get_query_var('paged'))?get_query_var('paged'):1;
每页$24;
//$offset=($page-1)*$每页;
$offset=($current-1)*$每页;
$big=99999999;//需要一个不太可能的整数
$total=sizeof($attachments);
$total_pages=圆形($total/$per_pages);
如果($总页数<($总页数/$每页))
{$total_pages=$total_pages+1;
}
//分页设置在此结束-------------------------------------//
//画廊输出从这里开始---------------------------------------//
$output=“\n”;
$counter=0;
$pos=0;
弗雷奇