How to integrate post from one site to others in Wordpress Multisite?

Asked

Viewed 2,592 times

0

I started using Wordpress’s Multisite.. I’m having difficulty calling some posts from one site to another. How can I do this within Multisite?

Searching, I found some codes to put on functions.php but they didn’t work...

  • It’s just like Eitch says. Here an example doing something similar to a shortcode. If you search my answers on WPSE and ONLY will find enough useful code. Good luck! . . PS: never use anything on functions.php to work with Multisite, is plugin or must use plugin.

1 answer

2

There are some ways to do it that you’re looking for. The simplest way (which serves many cases) is to use the RSS mechanism to replicate from one site to another.

For example, you want to "export" the category shared from your site, first you take the RSS URL of this category, which would be something like:

http://seusite/categoria/compartilhados/rss

And then use this URL in an RSS Syndication Plugin. This type of plugin reads an RSS and posts your content in the form of blog posts. One of these plugins is Feedwordpress, available in https://wordpress.org/plugins/feedwordpress/.

Another way is to use the function switch_to_blog to switch between blogs within a Multisite installation. By using this function, all code after it runs on another blog. For example, in the middle of your blog home one you can do something like this:

<?php
// muda para o blog de ID 2
switch_to_blog(2);

// prepara uma nova consulta com os 5 ultimos posts
wp_reset_query();
query_posts('showposts=5');

// usa o loop para mostrar os posts
if ( have_posts() ) :
  while ( have_posts() ) : the_post();
    get_template_part( 'content', get_post_format() );
  endwhile;
endif;

// importante: volta para o blog anterior
restore_current_blog();
?>

This way you can do all kinds of query items within a blog, to show on another blog the way you want.

Sources, in English, on the subject:

https://wordpress.stackexchange.com/questions/98965/get-posts-from-sites-in-multisite https://wordpress.stackexchange.com/questions/89113/restore-current-blog-vs-switch-to-blog https://wordpress.org/support/topic/how-do-you-query-posts-in-multisite-network

  • Damn, you mention some important posts there in WPSE, but you’re using query_posts?¿ :)

  • Living and learning... :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.