• hey guys,

    I would like to display the 5 latest posts from my bbpress forum within a seperated frontpage (phpfrontpage.php), which is located on the same server/directory as the WordPress installation

    like:
    Frontend/phpfrontpage.php
    Frontend/Blog

    I also wanted to list the last 5 Blogposts in the Blog. To do this, I simply included “/blog/wp-load.php” and did

    $recent_posts = wp_get_recent_posts(array(
    ‘numberposts’ => 5
    ));

    Is there a similiar way to do this for the latest bbpress topics instead of the latest blogposts?

    Thank you very much!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    wp_get-recent_posts() accepts a ‘post_type’ argument, simply pass whatever post type is used by bbpress in a second call. This is assuming bbpress is running in the same WP installation as your blog. This is not totally clear to me. Otherwise you should probably directly query the bbpress DB with mysqli_* functions to minimize overhead.

    You should know that explicitly including wp-load.php is considered bad practice, if not explicitly forbidden in some cases. IMO it’s OK if the use is limited to your own installation and you consider it non-portable code. There’s a few accepted ways to load the WP environment, in your case the best would be to make your frontpage a custom page template, then create a page post type based on it. This gives you a permalink for the page and ensures the WP environment is available to the template code.

Viewing 1 replies (of 1 total)
  • The topic ‘Show Latests Posts outside WordPress’ is closed to new replies.