Support » Plugins and Hacks » use locate_template twice in a same function

use locate_template twice in a same function

  • 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;


    //use set blog_id instead of current blog_id

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


    while (have_posts()) : the_post();

    //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;

  • The topic ‘use locate_template twice in a same function’ is closed to new replies.