Wordpress loop
2 naročnika
2 naročnika
Rad bi na eni custom strani prikazal prispevek (ki je bil kliknjen) in potem še spodaj (drugi "loop") še objave iz določene kategorije. Vse dela ok, edini problem je, da se podvoji objava iz prvega loopa v drugem.
Prvi loop
<?php if (haveposts()) :
while (haveposts()) : thepost(); ?>
<div <?php postclass() ?> id="post-<?php theID(); ?>">
<div class="entry">
<?php // Post Image
if( $udesignoptions['displaypostimageinsinglepost'] == 'yes' ) displaypostimagefn( $post->ID, false );
thecontent(('<p class="serif">Read the rest of this entry »</p>', 'udesign'));
wplinkpages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'nextor_number' => 'number')); ?>
</div>
<?php echo doshortcode('[dividertop]'); ?>
Drugi "loop"
<?php
$args = array( 'category' => 36, 'posttype' => 'post' );
$postslist = getposts( $args );
foreach ($postslist as $post) : setuppostdata($post);
?>
<h2><?php thetitle(); ?></h2>
<?php thecontent(); ?>
<?php echo doshortcode('[divider_top]'); ?>
<?php endforeach; ?>
Poskusil sem z
if(gettheID() == theExcludedID){
continue;
}
ampak ne deluje
Hvala za pomoč!
8 odgovorov
$args = array('exclude' =>theExcludedID, 'category' => 36, 'post_type' => 'post' );
in v excluded id shrani id prejšnjega posta .
v drugem loopu :
<?php
global $post;
$args = array('exclude' =>$post->ID, 'category' => 36, 'posttype' => 'post' );
$postslist = getposts( $args );
foreach ($postslist as $post) : setuppostdata($post);
?>
<h2><?php thetitle(); ?></h2>
<?php thecontent(); ?>
<?php echo doshortcode('[divider_top]'); ?>
<?php endforeach; ?>