Pereiti prie turinio

Wordpress custom loop page navi


Rekomenduojami pranešimai

Sveiki Wordpresui kūriau CUSTOM LOOP, kurio paskirtis naudoti VIDEOS atvaizdavimui, tačiau bėda yra tokia, kad nėra puslapiavimo, nelabai išeina padaryti, jeigu postų daugiau negu 13 turi atsirasti puslapiavimas, gal kas galit padėti? Mano kodo gabalas štai čia:

 

<?php
/* Start the Loop.
 *
 * In Twenty Ten we use the same loop in multiple contexts.
 * It is broken into three main parts: when we're displaying
 * posts that are in the gallery category, when we're displaying
 * posts in the asides category, and finally all other posts.
 *
 * Additionally, we sometimes check for whether we are on an
 * archive page, a search page, etc., allowing for small differences
 * in the loop on each template without actually duplicating
 * the rest of the loop that is shared.
 *
 * Without further ado, the loop:
 */ ?>

<?php
global $post;
$args = array( 'numberposts' => 100, 'category' => 13, 'paged' => $paged);
$myposts = get_posts( $args );
foreach( $myposts as $post ) :	setup_postdata($post); $loopcounter++; ?>

<?php if ($loopcounter  == 1) { ?>
<div class="matomas_video" id="post-<?php the_ID(); ?>">
   	<div class="matomas_vid"><?php $key="Video"; echo get_post_meta($post->ID, $key, true); ?></div>
       <div class="matomas_vid_info">

		<a style="margin-right: 10px;" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><a class="comments" href="<?php the_permalink() ?> #comments"><span><?php comments_number('(0)','(1)','(%)'); ?></span></a><?php the_excerpt(); ?>


	</div>
	<div class="clear"></div>
</div>

<div class="clear"></div>
<div class="video_list">

<?php } else { ?>
<div class="video" id="post-<?php the_ID(); ?>">
	<?php if(has_post_thumbnail()) { ?><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('video'); ?></a><?php } ?> 
       <div class="clear"></div>         	
	<strong><?php the_time('Y F j') ?></strong><br /><a style="margin-right: 10px;" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><a class="comments" href="<?php the_permalink() ?> #comments"><span><?php comments_number('(0)','(1)','(%)'); ?></span></a> 	
</div>
<?php } ?>     
<?php endforeach; ?>
</div>

<div class="clear"> </div>  

Nuoroda į pranešimą
Dalintis kituose puslapiuose

Jeigu manai, kad tai veikia, tai klysti :) Aš todėl ir teiraujuosi atsakymų :) Puslapiavimas kaip ir gerai, tačiau dabar negerai su $wp_query = new WP_Query ir kaip čia nurodyti kiek postų rodyti? nes neveikia numberpost => 13 :)

 

Padariau taip:

 

<?php
global $post;
$args = array( 'numberposts' => 10, 'category' => 13);
$myposts = get_posts( $args );
foreach( $myposts as $post ) :	setup_postdata($post); $loopcounter++; ?>

<?php if ($loopcounter  == 1) { ?>
<div class="matomas_video" id="post-<?php the_ID(); ?>">
   	<div class="matomas_vid"><?php $key="Video"; echo get_post_meta($post->ID, $key, true); ?></div>
       <div class="matomas_vid_info">

		<a style="margin-right: 10px;" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><a class="comments" href="<?php the_permalink() ?> #comments"><span><?php comments_number('(0)','(1)','(%)'); ?></span></a><?php the_excerpt(); ?>


	</div>
	<div class="clear"></div>
</div>

<div class="clear"></div>
<?php } ?>     
<?php endforeach; ?>
<div class="clear"> </div> 



<?php
 $temp = $wp_query;
 $wp_query= null;
 $wp_query = new WP_Query('cat=13&showposts=8&paged=' . $paged);
?>
<div class="video_list">

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="video" id="post-<?php the_ID(); ?>">
	<?php if(has_post_thumbnail()) { ?><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('video'); ?></a><?php } ?> 
       <div class="clear"></div>         	
	<strong><?php the_time('Y F j') ?></strong><br /><a style="margin-right: 10px;" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><a class="comments" href="<?php the_permalink() ?> #comments"><span><?php comments_number('(0)','(1)','(%)'); ?></span></a> 	
</div>
<?php endwhile; ?>

</div>
<div class="clear"></div>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }

 $wp_query = null; $wp_query = $temp; ?>

 

B4da, kad puslapiavimo neina daryti, jeigu naudoji foreach, eina daryti tik tuomet, kai darai WHILE, arba galbūt aš kitaip nemoku, tačiau bet kuriuo atveju, rezultatą išgavau tokį, kokį reikėjo :)

Nuoroda į pranešimą
Dalintis kituose puslapiuose
  • po 1 mėnesio...

Dabar pačiam prireikė to paties, prisiminiau šią temą, nieko naudingo neradau. Per google radau būtent to ko reikėjo: http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/ (čia tuo atveju jei kam iškils tokia pati problema, o daugumai dirbančių su WP manau ji iškils anksčiau ar vėliau)

Nuoroda į pranešimą
Dalintis kituose puslapiuose

Prisijunkite prie diskusijos

Jūs galite rašyti dabar, o registruotis vėliau. Jeigu turite paskyrą, prisijunkite dabar, kad rašytumėte iš savo paskyros.

Svečias
Parašykite atsakymą...

×   Įdėta kaip raiškusis tekstas.   Atkurti formatavimą

  Only 75 emoji are allowed.

×   Nuorodos turinys įdėtas automatiškai.   Rodyti kaip įprastą nuorodą

×   Jūsų anksčiau įrašytas turinys buvo atkurtas.   Išvalyti redaktorių

×   You cannot paste images directly. Upload or insert images from URL.

Įkraunama...
  • Dabar naršo   0 narių

    Nei vienas registruotas narys šiuo metu nežiūri šio puslapio.

  • Prisijunk prie bendruomenės dabar!

    Uždarbis.lt nariai domisi verslo, IT ir asmeninio tobulėjimo temomis, kartu sprendžia problemas, dalinasi žiniomis ir idėjomis, sutinka būsimus verslo partnerius ir dalyvauja gyvuose susitikimuose.

    Užsiregistruok dabar ir galėsi:

    ✔️ Dalyvauti diskusijose;

    ✔️ Kurti naujas temas;

    ✔️ Rašyti atsakymus;

    ✔️ Vertinti kitų žmonių pranešimus;

    ✔️ Susisiekti su bet kuriuo nariu asmeniškai;

    ✔️ Naudotis tamsia dizaino versija;

    ir dar daugiau.

    Registracija trunka ~30 sek. ir yra visiškai nemokama.

  • Naujausios temos

  • Karštos temos

×
×
  • Pasirinkite naujai kuriamo turinio tipą...