Skip to:
Content
Pages
Categories
Search
Top
Bottom

Where can I find the forum NAMES in the database?


  • Biswadip
    Participant

    @biswadip

    I am using WordPress 3.6.1 with plugins Buddypress 1.8.1 and bbpress 2.3. I am trying to import the latest topics and replies from specific bbpress forums into specific wordpress pages.

    I started with a Mysql query:

    $query=”SELECT * FROM wp_posts WHERE post_type = ‘topic’ OR post_type = ‘reply’ ORDER BY post_date DESC”;

    Then (in pseudo code) I planned to do the following:

    // since forum is a parent of topic which is a parent of reply
    // if post is topic get forum id
    // if post is reply get forum id from the parent of the topic
    //create an array of latest topics and replies associated with their forums
    //print latest topics and replies for each forum to different wordpress pages.

    The problem I cannot seem to solve is – where to get the name of the forum from? Without getting the name of the forum from somewhere in the database, my only option would seem to be to hardcode the forum id’s of each forum with their respective names. Which means every time a new forum is created this needs to be added in manually in the code. None of the tables I see in the wp database seems to contain the names of the different forums. Even if one of the other tables did contain it I am still not sure how I would then associate the forum id’s from the wp_posts table with the forum names from another table – presumably I would have to do some kind of join? Or maybe I am going about it completely the wrong way – is anyone able to help an inexperienced developer out of his depth navigate his way through this problem?

Viewing 4 replies - 1 through 4 (of 4 total)

  • Stephen Edgar
    Moderator

    @netweb

    The problem I cannot seem to solve is – where to get the name of the forum from? Without getting the name of the forum from somewhere in the database

    The ONLY place the forum name exists is in the database :/

    Just include the forum name and forum id into your logic, each topics `post_parent’ points to the parent forum id and then you can get the forum name at the same time.

    SELECT * FROM wp_posts WHERE post_type = ‘forum’


    Biswadip
    Participant

    @biswadip

    Thanks Stephen maybe you are right.

    Perhaps I was being too ambitious in hoping for a solution where the forum id can be used to access the forum name without me having to manually include the forum id and forum name in my code every time the user creates a new forum?

    And in which database table can I find the forum names pray tell? It is not in wp_posts as far as I can see.

    They are all in wp_posts just like topic & reply, forum is the post_type in wp_posts

    Modify your query that you linked in your original post:
    $query=”SELECT * FROM wp_posts WHERE post_type = 'forum' OR post_type = 'topic' OR post_type = 'reply' ORDER BY post_date DESC”;


    Biswadip
    Participant

    @biswadip

    Thank you so much. My mistake was not realising that there is a post type called forum.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.