Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter soyelnacho

    (@soyelnacho)

    great!
    works prefect!

    thank you very much MichaelH for you help and patient.

    thanks t31os_ too!

    ??

    Thread Starter soyelnacho

    (@soyelnacho)

    wow! it works!

    thanks!

    now, i have another problem…

    in the same page, after these query, i have another query, to show only one category posts…

    after added the new code, the seconds loops, didnt fin any post in these category, im receiving a ugly “No upcoming Events”.

    The code added to the first query:

    <?php
    function filter_where($where = '') {
    $where .= " AND post_date > '" .date('Y-m-d') . "'";
    return $where;
    }
    add_filter('posts_where', 'filter_where');
    
    $args = array(
    'cat' => -26,
    'showposts'=>10,
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'ASC'
    );
    $my_query = new WP_Query($args);
    
    if ($my_query->have_posts()) : while ($my_query->have_posts()) :
    $my_query->the_post();
    $do_not_duplicate = $post->ID;
    ?>
    
               ...posts code...
    
    <?php endwhile; else: ?>
    <?php _e('No upcoming Events'); ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>

    and, in mi second loop:

    <?php
    $my_query = new WP_Query('category_name=entrevistas&showposts=1');
    if ($my_query->have_posts()) : while ($my_query->have_posts()) :
    $my_query->the_post();
    $do_not_duplicate = $post->ID;
    ?>
    
            <?php the_title(); ?>
    
    <?php endwhile; else: ?>
    <?php _e('No upcoming Events'); ?>
    <?php endif; ?>

    Can you see the problem there?

    Thx!!

    Thread Starter soyelnacho

    (@soyelnacho)

    damn! did not work for me!

    try to explain it better.

    suppose today’s date is: October 13.
    I have in my database the following posts:

    * Post #1 (January 20)
    * Post #2 (March 15)
    * Post #3 (April 20)
    * Post #4 (May 5)
    * Post #5 (May 10)
    * Post #6 (June 5)
    * Post #7 (June 10)
    * Post #8 (July 6)
    * Post #9 (August 10)
    * Post #10 (September 20)
    * Post #11 (October 5)
    * Post #12 (October 15) <- must appear
    * Post #13 (November 3) <- must appear
    * Post #14 (November 10) <- must appear
    * Post #15 (November 16) <- must appear

    then, when I do the loop,
    saying the oldest must be listed first (post 12 first then post 13, then post 14, then post 15) the loops stats trying to print post 1, then post 2, then post 3, and so untill the post 10.

    The problem is, my first 10 post, are all from past date, so nothing is printed.

    Hope you can help me again!

    THX!

    hey!

    a found a solution…

    as seen at https://forums.digitalpoint.com/showthread.php?t=1022546

    go to wp-includes/classes.php
    find
    if ( isset($error) )
    $this->query_vars[‘error’] = $error;

    under it you need to place the following

    if (@$this->query_vars[“name”] == “page”)
    {
    $tmp_ar = $this->query_vars;
    $this->query_vars = array();
    $this->query_vars[“paged”] = str_replace(“/”, “”, $tmp_ar[“page”]);
    $this->query_vars[“category_name”] = $tmp_ar[“category_name”];
    }

    Thats it.

    works for me ??

Viewing 4 replies - 1 through 4 (of 4 total)