Skip to:
Content
Pages
Categories
Search
Top
Bottom

how to retrieve the content of a specific page from each blog and display it in the blogs directory

  • @gasparking

    Participant

    I have created a “info” page on each one of my blogs and want to display the content of this page in the blog-loop of the blogs directory page.
    Does someone have the solution ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @gasparking

    Participant

    nobody ?

    @nahummadrid

    Participant

    @gasparking

    Participant

    @nahummadrid

    in fact, i don’t need to retrieve the blog description as it has only one field.
    what i try is to get the content of a page (if possible with custom fields) from each blog.

    I am able to retrieve the title of the post with ID=1 from each blog
    here is what i’ve done so far

    in the blogs-loop.php

    global $blogs_template;
    $post_id=1;
    $info_post = get_blog_post($blogs_template->blog->blog_id,$post_id)->post_title;

    and it gets the post ID=1

    how to get a page (and not a post) with the name of the page ?
    i try to use get_page_by_title(‘info’); but it doesn’t work

    plz help

    @nahummadrid

    Participant

    @gasparking i think you’d be looking to work with post_type or post_title(i think), i’d start here https://codex.wordpress.org/WPMU_Functions/get_blog_post – sounds like something i’d like to try too.

    @boonebgorges

    Keymaster

    If you want to get content from different blogs on a WPMU/WPMS installation on a single BuddyPress page, you’ll probably have to use the function switch_to_blog(), and its partner restore_current_blog(). For example, if you run switch_to_blog(5) from your BP blog (I’m assuming it’s blog #1), any blog-specific functions you run (such as query_posts) will be with reference to blog 5 instead of blog 1. Use restore_current_blog() to switch back to blog 1.

    This method is pretty resource intensive, though, so it might not be the best choice if you’ve got a huge site.

    @gasparking

    Participant

    Thank you @boonegorges, i am now able to do it with switch_to_blog().
    I will have a maximum of 40 blogs. Hope this will not charge the server too much

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how to retrieve the content of a specific page from each blog and display it in the blogs directory’ is closed to new replies.
Skip to toolbar