I started using WordPress's Multisite. I'm having trouble calling a few posts from one site to another. How can I do this within Multisite?
Searching, I found some codes to put in functions.php
but they did not work ...
I started using WordPress's Multisite. I'm having trouble calling a few posts from one site to another. How can I do this within Multisite?
Searching, I found some codes to put in functions.php
but they did not work ...
There are a few ways to do this that you are wanting. The simplest way (which works for many cases) is to use the RSS engine to replicate from one site to another.
For example, you want to "export" the shared category of your site, you first get the RSS URL for this category, which would look like this:
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 posts within the blog. One such plugin is FeedWordPress, available at link .
Another way is to use the switch_to_blog function to switch between blogs within a MultiSite installation . When using this function, all code after it starts running 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 make all types of queries of items within a blog, to show in another blog in any way you want.
Sources, in English, on the subject: