WordPress.org

Ready to get started?Download WordPress

Forums

Avoid duplicated posts (5 posts)

  1. Firkraag85
    Member
    Posted 1 year ago #

    Hi,

    I followed this instructions and I could avoid the duplicate posts, but the matter is that I only display 3 posts on the differents colums... You'll see "Secundaria" in blank.

    How can I put posts_per_page=3 to show the last 3 post, but not duplicated, the previous ones, do you understand?

    I hope you can help me.

    Link: http://bit.ly/VAlj66

    A fragment of my code:

    <ul>
    				<!-- NOVEDADES SECUNDARIA -->
    				<?php query_posts('cat=1,-3,-4,-102,-100,-111&order=DESC&posts_per_page=3'); if ( have_posts() ) : while ( have_posts() ) : the_post();  if (!in_array($post->ID, $ids)) { ?>
    				<li id="gradeNews-<?php the_ID(); ?>">
    					<div class="postImage">
    						<a href="<?php the_permalink(); ?>"><?php echo get_post_image('thumbnail','','default-thumb'); ?></a>
    					</div>
    					<div class="postInfo">
    						<div class="postTitle">
    							<h4><a href="<?php the_permalink(); ?>" title="Link permanente a <?php the_title_attribute(); ?>"><?php short_title('','…',true, '35'); ?></a></h4>
    							<p class="postMeta"><?php the_time('j F, Y'); ?></p>
    						</div>
    					</div>
    				</li>
    				<?php } endwhile; else: ?>
    				<li><em>No hay noticias en Secundaria!</em></li>
    				<?php endif; ?>
    				<?php wp_reset_query();?>
    			</ul>

    Thanks you!

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    So you want to show the latest 3 posts that are in category id 1 and exclude posts from the former loops ($ids)?
    try:

    <?php
    $args= array(
    'cat' => 1,
    'posts_per_page' => '3',
    'post__not_in' => $ids,
    );
    query_posts($args);
    ?>

    http://codex.wordpress.org/Function_Reference/WP_Query#Post_.26_Page_Parameters

    Can you paste and submit the full code into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.

  3. Firkraag85
    Member
    Posted 1 year ago #

    Thanks you so much for your reply, yes, I want that, but apperently with what you say is not working for me also (my previous code) http://pastebin.com/embed_iframe.php?i=96dYDZ0s

    And the one that includes the modifications in SECUNDARIA: http://pastebin.com/embed_iframe.php?i=u9iBbgsN

    Thanks again, and again for your answer.

  4. Firkraag85
    Member
    Posted 1 year ago #

    Please forget my previous posts, now I do it again and now is "working", but I'm receiving this message: Warning: urldecode() expects parameter 1 to be string, array given in /home/firk/mysite/wp-includes/query.php on line 1737 (this also happens with '' in 'posts_per_page' = '3')

    You can see my full code here: http://pastebin.com/embed_js.php?i=FnMKRUve

    And my "dev" web here: http://bit.ly/VAlj66

    Thanks!

  5. Firkraag85
    Member
    Posted 1 year ago #

    I tried many things but I can't solve it. Can anybody help me please?

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.