• I have 2 wordpress websites running off the same database, but each with a different prefix. I need to be able to query from site1.com while using site2.com

    Something like this:

    <?php get_header(); ?>
    
    //Switch to 'pre1_'
    
    // The Query
    query_posts( $args );
    
    // The Loop
    while ( have_posts() ) : the_post();
    	echo '<li>';
    	the_title();
    	echo '</li>';
    endwhile;
    
    // Reset Query
    wp_reset_query();
    
    //Switch back to 'pre_2'
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

The topic ‘Change Database Prefix While in Loop’ is closed to new replies.