0

I need to get blog ids (or site ids) on my multisite, from permalinks.

THIS PROBLEM IS NOT A PLUGIN SPECIFIC, but here the full story: I listed the all network posts on my multisite to my network-home's homepage with "WDS Multisite Aggregate" plugin. This works fine, and the "aggregated" post's permalink's shows to the parent post's. (thus clarifying: The child posts will link back to the parent post.)

So, I have posts on my network's home with permalinks to the subsite's posts.

I want to get from these links the publisher subsite's id, because if I know these site's ids, I can get the publisher site's homeurl, like this:

$myblogid = [MISSING CODE, wherewith I get blog id from permalink] $mysuburl = get_home_url( $myblogid );

If I use the get_current_blog_id(), these getting the network's home id.

I know that, possible get blog id from url thus:

$blog_id = get_blog_id_from_url("example.com", "/blog1/"); or $blog_id = get_blog_id_from_url("blog1.example.com");

but this not working with post's permalinks, just only with blog urls.

very simplified: I have a permalink what this: subsite.network.com/post-url Now I want getting this: subsite.network.com

6
  • on which page do you need this home URL ? on the list of posts created by WDS Multisite Aggregate ?
    – mmm
    Jan 31 '18 at 22:42
  • yes, this plugin cloned the all posts from the network to the network home site... But these cloned post's permalinks shows to the parent's post. Jan 31 '18 at 22:43
  • (and the plugin automatically redirect the child posts to the parent posts, but this dont relevant.) Jan 31 '18 at 22:45
  • I want to use more than one page, that's why I thought this get_blogid's from permalink approach. Jan 31 '18 at 22:48
  • then on this list (your first comment) you want to replace post link like subsite.network.com/post-url with the link subsite.network.com ?
    – mmm
    Jan 31 '18 at 22:49
1

the plugin "WDS Multisite Aggregate" store the blog identifier in a meta of the cloned post. then in the template file wich display the cloned posts, you can retrieve the home url of the original website with that :

$blogid = $GLOBALS["post"]->blogid;
$blog_details = get_blog_details($blogid);
// the home URL is in $blog_details->home

I hope this is what you need because calculating the original post identifier from the permalink consumes considerably more ressources.

1

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .