WordPress.org

Ready to get started?Download WordPress

Forums

Pulling post for use on another site (3 posts)

  1. philaecom
    Member
    Posted 1 year ago #

    So I have wordpress installed with multi site network option. So I have 2 different blogs 1 word press install.

    http://blog.library.example.com
    http://blog.library.example/news/

    So this is where I'm running into problems. I want to use the informtion from the 2nd blog the news blog on another website. I see I have to use the get_posts() function. http://codex.wordpress.org/Template_Tags/get_posts However I see on one of the other docs http://codex.wordpress.org/Integrating_WordPress_with_Your_Website that this won't work for Multi Site Network

    Any links or suggestions you might be able to pass on would be much appreciated.

    -------
    Since get_posts() doesn't seem to work for multisite I was orginally goinh o use the WordPress RSS feed and parse xml on the site i needed. However that won't work for me because if a post has a link in it i won't get the link in the RSS.

    So this brings me to my next quesiton i was look into query the database directly. In the posts table for the blog I want to pull post from and noticed that the post was just the text and not formated text. What sort of query would you use so you get the links out of the database related to the post. What table is it stored in?

    Thanks,
    Phil

  2. michael.mariart
    Member
    Posted 1 year ago #

    The table that you'd be looking for is
    wp_posts
    That holds al of the posts that your site has. BUT... seeing as how your uisng a multi-site install, it will be something like wp1_posts or wp2_posts or whatever number has been assigned to it. Each blog has it's own table.

    You can get the post information by writing your own SQL query. You'd need to know which DB table to look at (wp1_, wp2_, etc) and you can extrct the information that way. There's no stadnard way to do this from another site. When you get the content, you can run it through the normal WordPress filters to have the formatting applied. One thing to remember is that any shortcodes that are enabled for one site, but not the other could cause issues if they are used in the post that you are trying to get.

  3. You can use get_posts on Multisite, you just have to use switch_to_blog first.

    But generally you don't want to replicate your data like that, as it adversely impacts SEO. Instead, I would use http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/ to pull in posts in an SEO friendly way.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.