Support » Networking WordPress » get_page_by_path not working with multisite

  • Hi, I’m using get_page_by_path in a function to retrieve the thumbnail of a post from the URL of the page (got from external source).
    It worked well but when I switched to multisite installation the function doesn’t work anymore.

    $url = "page-url"; (without hostname nor backslash)
    $page = get_page_by_path($url);

    returns nothing.
    I checked and $get_current_blog_id returns the right number (1).
    Even url_to_postid() doesn’t work.
    Do I have to call some other functions to get it work with multisite?
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Plugin Review Team Rep

    Are you 100% sure that the slug page-url is valid?



    Did you ever figure this out… I’m wondering if I’m having a similar issue with trying to use the below code, with get_path… on a multisite without luck… Thanks for the follow-up!

    $post = get_page_by_path('');
      $content = apply_filters('the_content', $post->post_content);
      echo $content;

    (I’m trying to post the same sample page content on multiple “example” sites, so I’m not worried about google ranking or anything for identical content…)


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_page_by_path not working with multisite’ is closed to new replies.