WordPress.org

Ready to get started?Download WordPress

Forums

use locate_template twice in a same function (1 post)

  1. grosbouff
    Member
    Posted 4 years ago #

    Hi, i'm creating a widget that fetches posts with query_posts then loads a template to display them.
    Problem :
    When I have two instances of that widget;
    the first loads the template but the second one does not do it.
    My queries are ok, posts are retrieven, it is just the template that does not load the second time.
    How I can do to use that template twice ?

    function display_list($instance) {
    global $bp;
    global $wpdb;
    global $wp_query;

    $classifieds_blog_id=$bp->classified3s->options['blog_id'];

    //use set blog_id instead of current blog_id
    $wpdb->set_blog_id($classifieds_blog_id);

    // going off on my own here
    $temp_query = $wp_query;

    query_posts('showposts='.$instance['showposts'].'&cat='.$instance['cat'].'&tag='.$instance['tag']);

    while (have_posts()) : the_post();

    //TEMPLATE
    //widget template if any
    if ( '' != locate_template( array( 'classified3s/classified3s-widgets-loop.php' ), false ) ) {
    locate_template( array( 'classified3s/classified3s-widgets-loop.php' ), true );
    }else {
    locate_template( array( 'classified3s/classified3s-loop.php' ), true );
    }
    // now back to our regularly scheduled programming
    $wp_query = $temp_query;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic