Support » Networking WordPress » List posts from outside a multisite blog

  • To make a long story short, I need to create a .php-file that fetches the permalinks to all the published posts on one of my blogs. I need to be able to direct link to the .php-file without any login, since it is going to be used for a cronjob.

    To describe my setup, I’m using WordPress 3.0 with multisite activated, and I need to get the posts from the blog with the virtual subfolder /blog. Lets say that WordPress is installed on http://www.example.com along with several blogs in the network, and that the blog I need to retrieve the posts from is accessed at http://www.example.com/blog.

    At first, I put the .php-file in the WordPress root (www.example.com), included wp-blog-header.php, and ran a custom loop in order to fetch all the published posts without any paging. Of course, the script couldn’t know that I wanted the posts from http://www.example.com/blog so the result was blank. Because the /blog subfolder is virtual and doesn’t exist in reality, I cannot put the .php-file in there.

    My second try was to put the .php-file inside the theme folder (www.example.com/wp-content/themes/my-theme), and then access it from http://www.example.com/blog/file.php, but then the WordPress security mechanism kicked in and returned a 404-error.

    My third try was to use $wpdb to get the rows, which at first seems to work. But since I need to fetch the permalink to each post (and I’m using fancy permalinks by the way), I would need to create quite a lof of complex queries (or at least one really complex) to spider through the way WordPress connect posts with the category and so on.

    So, after several hours of tearing my hair off, I’m asking you for help. Any ideas how to solve this problem?

Viewing 3 replies - 1 through 3 (of 3 total)
  • and I need to get the posts from the blog with the virtual subfolder /blog. Lets say that WordPress is installed on http://www.example.com along with several blogs in the network, and that the blog I need to retrieve the posts from is accessed at http://www.example.com/blog.

    that url is reserved for the archives of the main blog. So, the blog address with those urls would be the main domain of your site. only the entry’s permalinks will have the /blog in there.

    why not pull the feed? or the links in the archive pages?

    So basically you;re trying to show a list of all your posts, on another php-based site outside of WP?

    Thread Starter Werzie

    (@werzie)

    @andrea_r
    Hi! The virtual subfolder /blog was just an example, I’m using /blogg, which is the Swedish translation of blog.

    After listing all the permalinks to the posts, it is going to be sent to Facebook’s API in order to retreive the amount of likes for each page, which then are going to be stored in the local database (say, the post meta). As described in my first post, this .php-file will be accessed by a cronjob, in order to keep the numbers fresh.

    I’ve thought of using the blog’s feed, but I was hoping for a more simple solution using the loop.

    CodePoet

    (@design_dolphin)

    I’ve thought of using the blog’s feed, but I was hoping for a more simple solution using the loop.

    Hmmm I recently build a custom sitemap in PHP, created a page called ‘sitemap’, then created a page template sitemap.php in the root of the theme folder, and then assigned the page template to the ‘sitemap’ page. That did the trick, and it worked like a charm. A similar approach might work for you.

    Using a feed you might be able to use something like Feedwordpress.

    I don’t know how many subsites you have, and if you want to select just one from many, if applicable the following topic might help: How to search multiple blogs in one installation, and have one home page

    That’s all I can think off at the moment.

    Hope it helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘List posts from outside a multisite blog’ is closed to new replies.