Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to embed a page on the top of the forum page?


  • lauradimitra
    Participant

    @lauradimitra

    Hi all,

    I’m starting a community page in WordPress with the plugins bbPress and BuddyPress.

    I have a nice Forum page with my topics. At the top of the forum page I would like to have an overview about the topics with no replies for the logged in users with a certain role. So not a link to the page with all unanswered questions, but, if possible an overview of the questions.

    Is this possible? Thanks for your help!

    Kind regards,

    Laura

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

  • mithrandir
    Participant

    @mithrandir786

    It is definitely possible, to do so you will have to modify the template ‘content-archive-forum.php’
    you could use a custom loop to loop through the topics you would like to display based on the user role.

    Example:

    <div class="Featued">
        <?php
        //get current users user role
        $role = bbp_get_user_display_role(get_current_user_id());
        //if role is keymaster,moderator or participant display topics
        if ($role == "Keymaster" || $role == "Moderator" || $role == "Participant") {
            ?>
            <!--begin loop-->
            <?php
            $args = array('post_type' => 'topic', 'posts_per_page' => 10);
            $the_query = new WP_Query($args);
            if ($the_query->have_posts()) :
                ?>
                <!--the loop-->
                <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
                    <div>
                        <a class=”bbp-topic-permalink” href="<?php bbp_topic_permalink(); ?>"title=”<?php bbp_topic_title(); ?>”><?php bbp_topic_title(); ?></a>
                    </div>
                <?php endwhile; ?>
                <!--  end of the loop-->
                <?php wp_reset_postdata(); ?>
            <?php else: ?>
                <p><?php __e('Sorry, no posts matched your criteria.'); ?> </p>
            <?php
            endif;
            ?>
            <?php
        } elseif ($role == "Guest" || $role == "Blocked") {
            //do nothing
        }
        ?>
    </div>

    It is not very complicated depending on your level of expertise, but will require some knowledge of php and wordpress. If you could provide more information regarding what you are trying to achieve or any areas you are facing difficulty with, I can try my best to help out.


    lauradimitra
    Participant

    @lauradimitra

    Hi Mithrandir,

    thank you for your reply.

    I’m using the GeneratePress theme and I figured out that I don’t have (or cannot find) the template “content-archive-forum.php”. I’ve looked for it in my theme (GeneratePress) and the plugins bbPress and BuddyPress. Can you tell me where I can find it?

    I’m starting a forum for an open source product. One of our users prefers to see the unanswered questions immediately because he wants to help all user with an answer, so that’s the reason I’m asking it. My HTML and CSS skills are good,and now I’m using wordpress already for some months. My PHP knowledge is very basic and passive, but I’m used to it in WordPress.

    Kind regards,
    Laura


    mithrandir
    Participant

    @mithrandir786

    To find the location of the template files navigate to:
    ‘wp-content/plugins/bbpress/templates/default/bppress/’

    You will find all the template parts in this folder. It is recommended to not modify the files directly, instead create a folder named bbPress in the ‘generatepress’ theme root folder. ie. ‘wp-content/themes/generatepress/bbpress/’ copy any files you wish to modify into this folder. This way updates to bbPress wont overwrite any files you have modified and your changes wont be lost.

    Test this by copying the content-archive-forum.php to the newly created bbpress folder and begin to modify the file.

    a simple php echo command will confirm it is working by printing a message at the top of the content-forum-archive template.

    <?php echo "Hello world!"; ?>

    The Example provided in the previous reply can be pasted on top, or wherever you would like to display the topics. Some formatting is required, by adding appropriate div classes and styling with css as necessary. Would be happy to help with any of the html, php or wordpress functions if there is any difficulty.

    *my apologies if this a duplicate reply, previous reply did not get submitted properly,spam protection may have blocked it, since it included links to screenshots on imgur.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar