Hãy đăng ký thành viên để có thể dễ dàng trao đổi, giao lưu và chia sẻ về kiến thức đồ họa.
  1. Hãy đăng ký subscribe kênh Youtube mới của Việt Designer tại địa chỉ: Youtube.com/VietDesignerChannel để theo dõi các video về thiết kế đồ họa. Do trước đó kênh cũ bị Youtube quét không rõ lý do, trong thời gian chờ kháng cáo nếu các bạn thấy video trên diễn đàn bị die không xem được thì có thể vào kênh mới để tìm xem video sơ cua nhé.
    Loại bỏ thông báo

Hỏi về Pagination của theme Blanco

Chủ đề thuộc danh mục 'WordPress' được đăng bởi duyphung, 19/5/14.

Lượt xem: 2,533

  1. duyphung Mới đăng kí

    Ai đã sử dụng qua Theme bán hàng Blanco bản 2.9.2 hỗ trợ plugin wp-e-commerce hoặc woo-ecommerce có thể cho mình hỏi tí về Pagination.
    Mình bị vấn đề khi tùy chỉnh Permalinks sang định dạng Custom Structure: %postname% ->
    - Đối với plugin wp-e-commerce thì cái Pagination ko hoạt động được. Cụ thể là nhấn sang trang 2 là nó báo Not found vì nó ko hiểu cái URL sao khi rewrite với Permalinks.
    - Còn đối với plugin woo-ecommerce thì vẫn phân trang được nhưng cái banner phía trên thì ko load lên được.
    Đây là phần code:
    function etheme_pagination($totalpages = '', $per_page = '', $current_page = '', $page_link = '') {
    global $wp_query;
    $num_paged_links = 4; //amount of links to show on either side of current page

    $showFirstPageLink = false;
    $showLastPageLink = false;

    $additional_links = '';

    //additional links, items per page and products order
    if( get_option('permalink_structure') != '' ){
    $additional_links_separator = '?';
    }else{
    $additional_links_separator = '&';
    }
    if( !empty( $_GET['items_per_page'] ) ){
    $additional_links = $additional_links_separator . 'items_per_page=' . $_GET['items_per_page'];
    $additional_links_separator = '&';
    }
    if( !empty( $_GET['product_order'] ) )
    $additional_links .= $additional_links_separator . 'product_order=' . $_GET['product_order'];

    $additional_links = apply_filters('wpsc_pagination_additional_links', $additional_links);
    //end of additional links

    if(empty($totalpages)){
    $totalpages = $wp_query->max_num_pages;
    }
    if(empty($per_page))
    $per_page = (int)get_option('wpsc_products_per_page');

    $current_page = absint( get_query_var('paged') );
    if($current_page == 0)
    $current_page = 1;

    if(empty($page_link))
    $page_link = wpsc_a_page_url();

    //if there is no pagination
    if(!get_option('permalink_structure')) {
    $category = '?';
    if(isset($wp_query->query_vars['wpsc_product_category']))
    $category = '?wpsc_product_category='.$wp_query->query_vars['wpsc_product_category'];
    if(isset($wp_query->query_vars['wpsc_product_category']) && is_string($wp_query->query_vars['wpsc_product_category'])){

    $page_link = get_option('blogurl').$category.'&paged';
    }else{
    $page_link = get_option('product_list_url').$category.'&paged';
    }

    $separator = '=';
    }else{
    if ( isset( $wp_query->query_vars['wpsc_product_category'] ) ) {
    $category_id = get_term_by( 'slug', $wp_query->query_vars['wpsc_product_category'], 'wpsc_product_category' );
    $page_link = trailingslashit( get_term_link( $category_id, 'wpsc_product_category' ) );
    } else {
    $page_link = trailingslashit( get_option( 'product_list_url' ) );
    }
    $separator = 'page/';
    }

    // If there's only one page, return now and don't bother
    if($totalpages == 1)
    return;
    // Pagination Prefix
    $output = __('Pages: ','wpsc');

    if(get_option('permalink_structure')){
    // Should we show the FIRST PAGE link?
    if($current_page > 1 && $showFirstPageLink)
    $output .= "<a href=\"". esc_url( $page_link . $additional_links ) . "\" title=\"" . __('First Page', 'wpsc') . "\">" . __('&laquo; First', 'wpsc') . "</a>";

    // Should we show the PREVIOUS PAGE link?
    if($current_page > 1) {
    $previous_page = $current_page - 1;
    if( $previous_page == 1 )
    $output .= " <a class='prev_page' href=\"". esc_url( $page_link . $additional_links ) . "\" title=\"" . __('Previous Page', 'wpsc') . "\">" . __('&lt; Previous', 'wpsc') . "</a>";
    else
    $output .= " <a class='prev_page' href=\"". esc_url( $page_link .$separator. $previous_page . $additional_links ) . "\" title=\"" . __('Previous Page', 'wpsc') . "\">" . __('&lt; Previous', 'wpsc') . "</a>";
    }
    $i =$current_page - $num_paged_links;
    $count = 1;
    if($i <= 0) $i =1;
    while($i < $current_page){
    if($count <= $num_paged_links){
    if($count == 1)
    $output .= " <a href=\"". esc_url( $page_link . $additional_links ) . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), $i ) . " \">".$i."</a>";
    else
    $output .= " <a href=\"". esc_url( $page_link .$separator. $i . $additional_links ) . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), $i ) . " \">".$i."</a>";
    }
    $i++;
    $count++;
    }
    // Current Page Number
    if($current_page > 0)
    $output .= "<span class='current'>$current_page</span>";

    //Links after Current Page
    $i = $current_page + $num_paged_links;
    $count = 1;

    if($current_page < $totalpages){
    while(($i) > $current_page){

    if($count < $num_paged_links && ($count+$current_page) <= $totalpages){
    $output .= " <a href=\"". esc_url( $page_link .$separator. ($count+$current_page) .$additional_links ) . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), ($count+$current_page) ) . "\">".($count+$current_page)."</a>";
    $i++;
    }else{
    break;
    }
    $count ++;
    }
    }

    if($current_page < $totalpages) {
    $next_page = $current_page + 1;
    $output .= "<a href=\"". esc_url( $page_link .$separator. $next_page . $additional_links ) . "\" title=\"" . __('Next Page', 'wpsc') . "\">" . __('Next &gt;', 'wpsc') . "</a>";
    }
    // Should we show the LAST PAGE link?
    if($current_page < $totalpages) {
    $output .= "<a href=\"". esc_url( $page_link .$separator. $totalpages . $additional_links ) . "\" title=\"" . __('Last Page', 'wpsc') . "\">" . __('Last &raquo;', 'wpsc') . "</a>";
    }
    } else {
    // Should we show the FIRST PAGE link?
    if($current_page > 1 && $showFirstPageLink)
    $output .= "<a href=\"". remove_query_arg('paged' ) . "\" title=\"" . __('First Page', 'wpsc') . "\">" . __('&laquo; First', 'wpsc') . "</a>";

    // Should we show the PREVIOUS PAGE link?
    if($current_page > 1) {
    $previous_page = $current_page - 1;
    if( $previous_page == 1 )
    $output .= " <a class='prev_page' href=\"". remove_query_arg( 'paged' ) . $additional_links . "\" title=\"" . __('Previous Page', 'wpsc') . "\">" . __('&lt; Previous', 'wpsc') . "</a>";
    else
    $output .= " <a class='prev_page' href=\"". add_query_arg( 'paged', ($current_page - 1) ) . $additional_links . "\" title=\"" . __('Previous Page', 'wpsc') . "\">" . __('&lt; Previous', 'wpsc') . "</a>";
    }
    $i =$current_page - $num_paged_links;
    $count = 1;
    if($i <= 0) $i =1;
    while($i < $current_page){
    if($count <= $num_paged_links){
    if($i == 1)
    $output .= " <a href=\"". remove_query_arg('paged' ) . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), $i ) . " \">".$i."</a>";
    else
    $output .= " <a href=\"". add_query_arg('paged', $i ) . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), $i ) . " \">".$i."</a>";
    }
    $i++;
    $count++;
    }
    // Current Page Number
    if($current_page > 0)
    $output .= "<span class='current'>$current_page</span>";

    //Links after Current Page
    $i = $current_page + $num_paged_links;
    $count = 1;

    if($current_page < $totalpages){
    while(($i) > $current_page){

    if($count < $num_paged_links && ($count+$current_page) <= $totalpages){
    $output .= " <a href=\"". add_query_arg( 'paged', ($count+$current_page) ) . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), ($count+$current_page) ) . "\">".($count+$current_page)."</a>";
    $i++;
    }else{
    break;
    }
    $count ++;
    }
    }

    if($current_page < $totalpages) {
    $next_page = $current_page + 1;
    $output .= "<a class='next_page' href=\"". add_query_arg( 'paged', $next_page ) . "\" title=\"" . __('Next Page', 'wpsc') . "\">" . __('Next &gt;', 'wpsc') . "</a>";
    }
    // Should we show the LAST PAGE link?
    if($current_page < $totalpages && $showLastPageLink) {
    $output .= "<a href=\"". add_query_arg( 'paged', $totalpages ) . "\" title=\"" . __('Last Page', 'wpsc') . "\">" . __('Last &raquo;', 'wpsc') . "</a>";
    }
    }
    // Return the output.
    echo $output;
    }


    Mình tải theme Blanco bản 2.9.2 về dùng thử và bị như trên, ai đã dùng qua mà khắc phục được xin chỉ giúp. Thanks!

    Y: DJpro_01
    Sky: duyphung1988
    E: duyphung1988@gmail.com

    ...
    Chỉnh sửa lần cuối: 20/5/14
  2. duyphung

    duyphung Mới đăng kí

    Có ai biết chỉ dùm

Ủng hộ diễn đàn