2016-08-22 7 views
0

このタイプのエラーを解決する方法はありません。私のワードプレスのsite.Allのページングを追加しました。 、3,4 ... etcページではクラスを変更しません.currentなぜそれが.currentクラスのCSSを取得しないのですか?ギャラリーの。現在のクラスは、WordPressサイトのページ番号をクリックしたときに変更されません。

機能コード:

function jellythemes_gallery($atts, $content=null) { 
    extract(shortcode_atts(array(
     'limit' => -1 
     ), $atts)); 
    global $post; 
    $back=$post; 
    echo '<div id="portfolio"> 
       <div class="section portfoliocontent"> 
        <section id="i-portfolio" class="clear">'; 

     // set up or arguments for our custom query 
     $paged = (get_query_var('page')) ? get_query_var('page') : 1; 
     $query_args = array(
     'post_type' => 'media', 
     'posts_per_page' => 12, 
     'paged' => $paged 
    ); 
     // create a new instance of WP_Query 
     $the_query = new WP_Query($query_args); 

    if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); 

       $image = get_post_meta($post->ID, '_jellythemes_media_photo', true); 
       $video = get_post_meta($post->ID, '_jellythemes_media_video', true); 
       $img = wp_get_attachment_image_src($image, 'media_thumb'); 

       echo '<div class="ch-grid element"> 
           <img class="ch-item" src="' . $img[0] .'" alt="' . get_the_title() . '" />'; 
       if (empty($video)) { 
        echo '<a class="fancybox img-lightbox" rel="" href="' . $img[0] .'">'; 
       } else { 
        echo '<a class="fancybox-media" rel="" href="' . $video.'">'; 
       } 
       echo '<div> 
         <span class="p-category ' . (empty($video) ? 'photo' : 'video') . '"></span> 
          </div> 
          </a> 
          </div>'; 
    endwhile; 

      $post=$back; //restore post object 
    $return .= '</section> 
      </div> 
     </div>'; 

    echo "<div class='pagination_center'>"; 
    if ($the_query->max_num_pages > 1) { 
       $current_page = max(1, get_query_var('paged')); 

       echo paginate_links(array(
        'base' => get_pagenum_link(1) . '%_%', 
        'format' => '/page/%#%', 
        'current' => $current_page, 
        'total' => $the_query->max_num_pages, 
        'show_all' => true, 
        'prev_text' => __('« PREV'), 
        'next_text' => __('NEXT »'), 
        'prev_next' => false, 
       )); 
    } 

    else{ 
     echo '<article> 
     <h1>Sorry...</h1> 
     <p>';echo 'Sorry, no posts matched your criteria.'; echo'</p> 
     </article>'; 
    } 
    endif; 
    echo "</div>"; 

    return $return; 
} 
add_shortcode('jellythemes_gallery', 'jellythemes_gallery'); 

は、CSSは:ここ

.pagination_center .current{ 
border: 1px solid #c3121c; 
    padding: 0px 5px; 
    color: black; 
    font-weight: bold; 
    background: #c3121c; 
} 

は私が検査をimageを追加element.Itは2ページが、ページ1.Canの.currentクラスです誰が問題をどこに教えてくれる?

ありがとうございます。さらにコードが必要な場合は教えてください。

+0

を表示することができますか?ページコード –

+0

@ChoncholMahmud:ここでクラスを追加するJSコードはどこですか? –

+0

あなたはここで答えを読むことができますか?http://wordpress.stackexchange.com/questions/126080/changing-pagination-list-class –

答えて

0

次のページのベースを交換する必要があります。恐らく問題は%_%%#%であり、テストをしないとそれほど役に立たないようです。しかし、以下のコードを試してください。

$big = 999999999; // need an unlikely integer 
echo paginate_links(array(
    'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 
    'format' => '/page/%#%', 
    'current' => $current_page, 
    'total' => $the_query->max_num_pages, 
    'show_all' => true, 
    'prev_text' => __('« PREV'), 
    'next_text' => __('NEXT »'), 
    'prev_next' => false, 
)); 

お手数ですが、また、Paginate Links

+0

私はテストしましたが、動作していません。 '.current'クラスはページ1にあります。全く変化しません。 –

+0

'$ current_page'の値は' $ current_page = max(1、get_query_var( 'paged'))の後にあります; 'それはインクリメントされているかどうかです。 –

+0

ページネーションはその値を変更しますが、 '.current'クラスを変更しません。 –

関連する問題