1

Hy everyone! I listed the all network posts on my multisite to my network-home's homepage with "WDS Multisite Aggregate" plugin. This works fine, but now I want to get the author/publisher subsite's domains above each posts, similar to: by Author_name, just in this case so: via subsite_url.

So now, if Author1 publishing on his own site, example [subsite1.network.com] a new post, this post immediately appears on the homepage of [network.com], and appear above of the post content the Author's username, thus: by Author1.

Besides this, the all "shared" post's link-title control to the publisher site, so example, when on the homepage of [network.com] a new post appears, this post title shows to [subsite.network.com/current-post-idx] when I use this the_title( sprintf( '<h2 class="entry-title" style="" itemprop="headline"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); and if I open [network.com/current-post-idx], this redirect to [subsite.network.com/current-post-idx].

So, get_permalink() shows to the original post where the author publishing that.

Now I would like that similar to this appear above of the post content the Author's site, where can he publishing the current post, thus: via [subsite1.network.com].

So, if get_permalink() = [subsite1.network.com/current-post-idx], in this same case how can I get simply [subsite1.network.com]?

... get_home_url() and get_site_url() obviously shows to [network.com] because that particular homepage it belongs this.

Sorry, this is my first question here, ago this I find everything on the subject on the internet, but about this I did't find anything anywhere.

  • Can you please edit your question to show us the code you're using to make subsite1's posts appear on network.com? – Pat J Jan 10 '18 at 4:03
  • I use the "Multisite Aggregate" plugin to this, and on the homepage of [network.com] I list the posts with "Ajax Load More" plugin with this shortcode [ajax_load_more container_type="div" post_type="post" posts_per_page="30" transition_container="false" images_loaded="true" button_label="Older Tumbs" button_loading_label="Loading Tumbs ..." transition="masonry" masonry_selector=".inside-article2" category__not_in="37"]. – Galgóczi Levente Jan 10 '18 at 4:14
  • Ah, I somehow managed to miss the plugin note (even though it's right at the start of your question). Have you checked with the Multisite Aggregate plugin support streams? They might have an answer for you. – Pat J Jan 10 '18 at 4:16
  • Not yet, but my first thought was, this can be solved elsewhere, because on [network.com] the all "shared" post's link-title control to the publisher site, so example, when on the homepage of [network.com] a new post appears, this post title shows to [subsite.network.com/current-post-idx] when I use this the_title( sprintf( '<h2 class="entry-title" style="" itemprop="headline"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); and if I open [network.com/current-post-idx], this redirect to [subsite.network.com/current-post-idx]. – Galgóczi Levente Jan 10 '18 at 4:31
  • So get_permalink() shows to the original post where the author publishing that. – Galgóczi Levente Jan 10 '18 at 4:33
1

Instead of get_site_url(), use get_home_url(). This will return the URL of the site you're in.

You can also get the URL of a different site in your Multisite network by passing that site's blog_id (ie, $url = get_home_url( 2 );).

(I suspect that get_site_url() is a holdover from the early days of Multisite; when Multisite was originally moved into WordPress, you created a site of blogs. The terminology has evolved, so that we now think of a network of sites, but some of the functions still reflect the old terms.)

  • Hy Pat, thanks for your fast reply! The problem is, the plugin dynamically fills to the main site's home every new post in the network, so the blog_id (in $url = get_home_url( 2 );) need it has to change dynamically, based on, where did the plugin fill it the post, so what sites on publishing the current post. – Galgóczi Levente Jan 10 '18 at 3:23
  • Please edit your question and add in some more code, for some context, it might be easier to help you solve your problem. Show us what you've got so far, and explain fully what you're trying to accomplish. – Pat J Jan 10 '18 at 3:28
0

The ultimate answer here, if you have a subdomain based multisite

(This works in every case with subdomain based multisite, if your canonical URLs are okay -> so your permalinks shows to the parent posts...).

Only replace the yournetworkdomain.com to your network domain:

$posturl = esc_url( get_permalink() );
$find = array( 'http://', 'https://' );
$replace = '';
$purepostaddress = str_replace( $find, $replace, $posturl );
$afterdomain = explode('yournetworkdomain.com', $purepostaddress);
$currentpostslug = $afterdomain[1];
$find = array( '' . $currentpostslug . '' );
$replace = '';
$parentblogaddress = str_replace( $find, $replace, $purepostaddress );

$blogid = get_blog_id_from_url('' . $parentblogaddress . '');
$blog_details = get_blog_details($blogid);

And so get the parent blog's link:

echo '<a href="' . get_home_url( $blogid ) . '" 
target="_blank">'.$blog_details->blogname.'</a>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.