• Hi all,
    I have 2 wp installation with 2 database on single server.
    I’d like to query database1 from wp2 just for retrieving post marked as ‘post_type’=> ‘appuntamenti’.

    How can I modify following code?
    global $wp_query; $maxnum = $wp_query->found_posts; is querying db2 instead of db1.

    <?php /*<a target="_blank" href="https://cblive.it/wp/wp-content/uploads/2014/05/codice_autoregolamentazione.pdf"><img src="https://cblive.it/wp/wp-content/uploads/2014/05/codiceBtn.png" /></a>
    */ ?><div id="appuntamenti_widget">
        <h3><a href="/notizie-molise/">Notizie dal Molise</a></h3>
        <div class="content">
            <?php
                    query_posts(array(
    
                        'post_type'=> 'appuntamenti',
                        'posts_per_page'=>10
                    ));
                while(have_posts()) : the_post();
                global $wp_query; $maxnum = $wp_query->found_posts;
             ?>
    
             <div id="featured-<?php the_ID();?>">
    
                <h2 class="entry-title">
                    <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'themejunkie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?> <?php the_post_thumbnail(featured-thumb); ?></a>
                </h2>
            </div>
    
            <?php endwhile; wp_reset_query(); ?>
        </div>
    </div>

    Any help is greatly appreciated.
    Thank you

  • The topic ‘Retrieving specific post type from different wp database’ is closed to new replies.