• I have two different blogs. On my homepage I want the latest posts in a certain category from each Blog. How can I do that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try a feedreader and RSS feeds.

    You can find some info here.

    Essentially, you need something like
    $today = current_time('mysql', 1);

    if ( $recentposts = $wpdb->get_results("SELECT ID, post_title, post_date FROM wp_posts_table LEFT JOIN wp_post2cat_table ON wp_posts_table.ID = wp_post2cat_table.post_id WHERE post_status = 'publish' AND post_date_gmt < '$today' AND category_id = XX ORDER BY post_date DESC LIMIT 10")): ?>

    This is presuming you have the blogs in the same database, with different prefixes. Where you substitute wp_post2cat_table and wp_posts_table with the name of your tables and for category_id = XX you enter the number of your category in place of XX.

    And then you output results in a loop like:
    <?php
    foreach ($recentposts as $post) {
    echo $post->post_title; and so on….

    Thread Starter xraysierra

    (@xraysierra)

    Unfortunatley I have the blogs in different databases, what would I do then?

    It makes things more complicated, because you don’t have the ease and form of the $wpdb object to work with. You’d have to create separate connections in php through its mysql connections if you were to take content directly and manipulate it.

    You might as well pull content from your rss feeds. Try fetch_rss, and you can retrieve feeds to specific categories on your site by adding the following to the end of the link:

    https://example.com/wp1/wp-rss2.php?cat=42

    of course, you’ll need to adapt this link to each installation.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How Do I Bring Up Posts From Two Blogs?’ is closed to new replies.