Witam dostalem oto takie zadanie na stronce w przykladowej zakladce mam 73 (okladki graficzne) na jednej stronie mam zrobic "paginacje" mianowicie chodzi o to aby zrobic
tak aby podzelic to na strony i na kazdej ma byc po 16 okladek. Pomocy
$okladki = ['okladka1.jpg', 'jakasokladka2.png', ... ,'okladka73.gif'];
$chce_zeby_bylo_ich_na_stronie = 16; $aktualna_strona = (int)$_GET['strona']; //jakaś obsluga, że $aktualna_strona >=0 i < $tyle_bede_mial_stron $indeks_pierwszej_okladki = $aktualna_strona * $chce_zeby_bylo_ich_na_stronie; $indeks_ostatniej_okladki = ($aktualna_strona + 1) * $chce_zeby_bylo_ich_na_stronie; if($indeks_ostatniej_okladki > $mam_tyle_okladek){ $indeks_ostatniej_okladki = $mam_tyle_okladek; }
//wyswietlamy okladki for($i = $indeks_pierwszej_okladki; $i < $indeks_ostatniej_okladki; $i++){ }
//wyswietlamy paginacje for($i = 0; $i < $tyle_bede_mial_stron; $i++){ if($i == $aktualna_strona){ //aktualna strona będzie pogrubiona } else { } }
<?php // Template Name: Afisze get_header(); ?> <style> /* Colorbox Core Style: The following CSS is consistent between example themes and should not be altered. */ #colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;} #cboxWrapper {max-width:none;} #cboxOverlay{position:fixed; width:100%; height:100%;} #cboxMiddleLeft, #cboxBottomLeft{clear:left;} #cboxContent{position:relative;} #cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;} #cboxTitle{margin:0;} #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;} #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;} .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;} .cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;} #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;} /* User Style: Change the following styles to modify the appearance of Colorbox. They are ordered & tabbed in a way that represents the nesting of the generated HTML. */ /* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */ #cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;} #cboxSlideshow{position:absolute; bottom:4px; right:30px; color:#0092ef;} #cboxPrevious{position:absolute; bottom:0; left:0; background:url(images/controls.png) no-repeat -75px 0; width:25px; height:25px; text-indent:-9999px;} #cboxPrevious:hover{background-position:-75px -25px;} #cboxNext{position:absolute; bottom:0; left:27px; background:url(images/controls.png) no-repeat -50px 0; width:25px; height:25px; text-indent:-9999px;} #cboxNext:hover{background-position:-50px -25px;} #cboxClose{position:absolute; bottom:0; right:0; background:url(images/controls.png) no-repeat -25px 0; width:25px; height:25px; text-indent:-9999px;} #cboxClose:hover{background-position:-25px -25px;} /* The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9. */ .cboxIE #cboxTopLeft, .cboxIE #cboxTopCenter, .cboxIE #cboxTopRight, .cboxIE #cboxBottomLeft, .cboxIE #cboxBottomCenter, .cboxIE #cboxBottomRight, .cboxIE #cboxMiddleLeft, .cboxIE #cboxMiddleRight { filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=# 00FFFFFF); } </style> <?php function przyjazny_string($string){ $string = str_replace(array('ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż','Ł'), array('a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z','l'), $string); return $string; } 'posts_per_page' => 100, 'offset' => 0, 'category' => get_post_field('Kategorie', get_the_ID()), 'category_name' => '', 'orderby' => 'date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => true ); $posts_array = get_posts( $args ); //print_r($posts_array); ?> <div > <?php foreach ($posts_array as $k=>$w) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $w->ID ), 'large' ); ?> <div class="plakat"> <?php ?> </a> <br> <div class="opis_plakatu"> <br> </div> </div> <!-- <div class="col-md-3 col-sm-6"> <div class="single-item"> ?></a> <div class="desc"> <p> </p> </div> </div> </div> --> <?php //exit(); } ?> </div> <script> jQuery(document).ready(function() { /* This is basic - uses default settings */ jQuery("a.single_image").colorbox({maxHeight:"90%",opacity:0.8,current:"Obraz {current} z {total}",previous:"Wstecz",next:"Dalej",close:"Zamknij"}); //fancybox(); }); </script> <?php get_footer(); ?>